You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/04/26 05:11:57 UTC

[GitHub] jlahoda closed pull request #512: [NETBEANS-710] Ensure the javac's module system is initialized before…

jlahoda closed pull request #512: [NETBEANS-710] Ensure the javac's module system is initialized before…
URL: https://github.com/apache/incubator-netbeans/pull/512
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java.hints.declarative/nbproject/project.xml b/java.hints.declarative/nbproject/project.xml
index 8908c51d5..09d333e72 100644
--- a/java.hints.declarative/nbproject/project.xml
+++ b/java.hints.declarative/nbproject/project.xml
@@ -372,6 +372,10 @@
                         <code-name-base>org.netbeans.modules.java.hints.declarative.test</code-name-base>
                         <compile-dependency/>
                     </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.j2seplatform</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
                     <test-dependency>
                         <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
                     </test-dependency>
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/ClassPathProviderImpl.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/ClassPathProviderImpl.java
index 9a13ba4dd..4d0d37bf2 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/ClassPathProviderImpl.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/ClassPathProviderImpl.java
@@ -33,10 +33,8 @@
 
     public ClassPath findClassPath(FileObject file, String type) {
         if ("hint".equals(file.getExt())) {
-            if (ClassPath.BOOT.equals(type)) {
-                return MethodInvocationContext.computeClassPaths()[0];
-            } else if (ClassPath.COMPILE.equals(type)) {
-                return MethodInvocationContext.computeClassPaths()[1];
+            if (ClassPath.COMPILE.equals(type)) {
+                return MethodInvocationContext.computeCompileClassPath();
             }
         }
 
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
index ddfe29662..bf4729c68 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
@@ -477,6 +477,7 @@ public void stateChanged(ChangeEvent e) {
         JavaSource.create(cpInfo).runUserActionTask(new Task<CompilationController>() {
             @SuppressWarnings("fallthrough")
             public void run(CompilationController parameter) throws Exception {
+                parameter.toPhase(JavaSource.Phase.RESOLVED);
                 if (invocation == null || invocation.length() == 0) {
                     //XXX: report an error
                     return ;
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/Hacks.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/Hacks.java
index fd10dada8..7ff8c2790 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/Hacks.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/Hacks.java
@@ -75,13 +75,12 @@ public static Scope constructScope(CompilationInfo info, String... importedClass
 
     private static final String SOURCE_LEVEL = "1.8"; //TODO: could be possibly inferred from the current Java platform
 
-    public static Map<String, byte[]> compile(ClassPath boot, ClassPath compile, final String code) throws IOException {
+    public static Map<String, byte[]> compile(ClassPath compile, final String code) throws IOException {
         DiagnosticListener<JavaFileObject> devNull = new DiagnosticListener<JavaFileObject>() {
             public void report(Diagnostic<? extends JavaFileObject> diagnostic) {}
         };
         StandardJavaFileManager sjfm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(devNull, null, null);
 
-        sjfm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, toFiles(boot));
         sjfm.setLocation(StandardLocation.CLASS_PATH, toFiles(compile));
 
         final Map<String, ByteArrayOutputStream> class2BAOS = new HashMap<String, ByteArrayOutputStream>();
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/MethodInvocationContext.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/MethodInvocationContext.java
index cf822f774..13f874700 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/MethodInvocationContext.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/MethodInvocationContext.java
@@ -231,10 +231,8 @@ void setCode(String imports, Iterable<? extends String> blocks) {
 
         code.append("}\n");
 
-        ClassPath[] classpaths = computeClassPaths();
-
         try {
-            final Map<String, byte[]> classes = Hacks.compile(classpaths[0], classpaths[1], code.toString());
+            final Map<String, byte[]> classes = Hacks.compile(computeCompileClassPath(), code.toString());
 
             if (!classes.containsKey("$." + className)) {
                 //presumably an error in the custom code, skip
@@ -271,14 +269,8 @@ void setCode(String imports, Iterable<? extends String> blocks) {
         "import org.netbeans.modules.java.hints.declarative.conditionapi.Variable;"
     };
 
-    static ClassPath[] computeClassPaths() {
-        ClassPath boot = JavaPlatform.getDefault().getBootstrapLibraries();
-        ClassPath compile = ClassPathSupport.createClassPath(apiJarURL());
-
-        return new ClassPath[] {
-            boot,
-            compile
-        };
+    static ClassPath computeCompileClassPath() {
+        return ClassPathSupport.createClassPath(apiJarURL());
     }
 
     public static URL apiJarURL() {
diff --git a/java.source/test/unit/src/org/netbeans/modules/java/TestJavaPlatformProviderImpl.java b/java.source/test/unit/src/org/netbeans/modules/java/TestJavaPlatformProviderImpl.java
index acefa280e..57b4b9095 100644
--- a/java.source/test/unit/src/org/netbeans/modules/java/TestJavaPlatformProviderImpl.java
+++ b/java.source/test/unit/src/org/netbeans/modules/java/TestJavaPlatformProviderImpl.java
@@ -31,6 +31,7 @@
 import org.netbeans.api.java.platform.JavaPlatform;
 import org.netbeans.modules.java.platform.implspi.JavaPlatformProvider;
 import org.netbeans.api.java.platform.Specification;
+import org.netbeans.modules.java.source.BootClassPathUtil;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileStateInvalidException;
@@ -82,24 +83,7 @@ public Map getProperties() {
 
         private static synchronized ClassPath getBootClassPath() {
             if (bootClassPath == null) {
-                String cp = System.getProperty("sun.boot.class.path");
-                List<URL> urls = new ArrayList<>();
-                String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
-                for (String path : paths) {
-                    File f = new File(path);
-
-                    if (!f.canRead())
-                        continue;
-
-                    FileObject fo = FileUtil.toFileObject(f);
-                    if (FileUtil.isArchiveFile(fo)) {
-                        fo = FileUtil.getArchiveRoot(fo);
-                    }
-                    if (fo != null) {
-                        urls.add(fo.toURL());
-                    }
-                }
-                bootClassPath = ClassPathSupport.createClassPath((URL[])urls.toArray(new URL[0]));
+                bootClassPath = BootClassPathUtil.getBootClassPath();
             }
             return bootClassPath;
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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