You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2018/04/25 05:09:40 UTC

[incubator-netbeans] branch master updated: [NETBEANS-654] Ignoring InvalidFileException while constructing the JavacTask, it will be thrown again and handled if needed. (#510)

This is an automated email from the ASF dual-hosted git repository.

jlahoda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c1ad06  [NETBEANS-654] Ignoring InvalidFileException while constructing the JavacTask, it will be thrown again and handled if needed. (#510)
2c1ad06 is described below

commit 2c1ad0655b5e9fe89a4e38a8cef51c4ffdabd70c
Author: Jan Lahoda <la...@gmail.com>
AuthorDate: Wed Apr 25 07:09:36 2018 +0200

    [NETBEANS-654] Ignoring InvalidFileException while constructing the JavacTask, it will be thrown again and handled if needed. (#510)
---
 .../netbeans/modules/java/source/parsing/JavacParser.java   | 12 +++++++++---
 .../modules/java/source/parsing/JavacParserTest.java        | 13 +++++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
index 78dc9c1..3aa15da 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
@@ -727,9 +727,15 @@ public class JavacParser extends Parser {
             }
             AbstractSourceFileObject source = null;
             if (file != null) {
-                source = FileObjects.sourceFileObject(file, root);
-                if (source.getKind() != Kind.SOURCE) {
-                    source = null;
+                try {
+                    source = FileObjects.sourceFileObject(file, root, null, false);
+                    if (source.getKind() != Kind.SOURCE) {
+                        source = null;
+                    }
+                } catch (FileObjects.InvalidFileException ife) {
+                    //ignore, it will be handled again later, see #parse.
+                } catch (IOException ex) {
+                    throw new IllegalStateException(ex);
                 }
             }
             final JavacTaskImpl javacTask = createJavacTask(cpInfo,
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
index b2acdc8..2f9b75b 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
@@ -315,6 +315,19 @@ public class JavacParserTest extends NbTestCase {
         }, true);
     }
     
+    public void testInvalidFile654() throws Exception {
+        FileObject f = createFile("test/Test.java", "package test; class Test { }");
+        JavaSource js = JavaSource.forFileObject(f);
+
+
+        js.runUserActionTask(new Task<CompilationController>() {
+            public void run(CompilationController parameter) throws Exception {
+                f.delete();
+                assertTrue(Phase.RESOLVED.compareTo(parameter.toPhase(Phase.RESOLVED)) <= 0);
+            }
+        }, true);
+    }
+
     public void testIfMissingObjectOnBootCPUseCPToGuessSourceLevel() throws Exception {
         Source ret = guessSourceLevel(false, false, false);
         assertEquals("Downgraded to 1.4", Source.JDK1_4, ret);

-- 
To stop receiving notification emails like this one, please contact
jlahoda@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists