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/06/18 04:40:02 UTC

[GitHub] jlahoda closed pull request #544: Fixing problems with watches evaluation on (not only) the upcoming JD…

jlahoda closed pull request #544: Fixing problems with watches evaluation on (not only) the upcoming JD…
URL: https://github.com/apache/incubator-netbeans/pull/544
 
 
   

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/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/IntroduceClass.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/IntroduceClass.java
index c76fbd71a..612d06a83 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/IntroduceClass.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/IntroduceClass.java
@@ -124,6 +124,7 @@ boolean computeIntroduceMethod(TreePathHandle h, CompilationInfo info, TreePath
                 lsBegin -= codeOffset;
                 this.snippetCode = new StringBuilder(this.snippetCode)
                         .insert((int) lsBegin, "return ")
+                        .append(';')
                         .toString();
             }
             if (returnType == null) {
diff --git a/debugger.jpda/nbproject/project.properties b/debugger.jpda/nbproject/project.properties
index 46316d09d..ab2561ab1 100644
--- a/debugger.jpda/nbproject/project.properties
+++ b/debugger.jpda/nbproject/project.properties
@@ -25,5 +25,6 @@ requires.nb.javac=true
 spec.version.base=1.110.0
 test-unit-sys-prop.test.dir.src=${basedir}/test/unit/src/
 test-unit-sys-prop.netbeans.user=${basedir}/work/nb_user_dir
+test.unit.cp.extra=../java.source.nbjavac/build/test-nb-javac/cluster/modules/org-netbeans-modules-java-source-nbjavac-test.jar
 
 
diff --git a/debugger.jpda/nbproject/project.xml b/debugger.jpda/nbproject/project.xml
index 814e374ac..14cbb11ba 100644
--- a/debugger.jpda/nbproject/project.xml
+++ b/debugger.jpda/nbproject/project.xml
@@ -183,6 +183,11 @@
                         <code-name-base>org.netbeans.modules.java.source</code-name-base>
                         <recursive/>
                     </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.source.nbjavac</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
                     <test-dependency>
                         <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
                         <recursive/>
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
index 04edbe72c..614b7c7a8 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
@@ -1992,7 +1992,7 @@ public Mirror visitIdentifier(IdentifierTree arg0, EvaluationContext evaluationC
                 identifierPath = getCurrentPath();
             }
             elm = evaluationContext.getTrees().getElement(identifierPath);
-            if (elm instanceof TypeElement && ((TypeElement) elm).asType() instanceof ErrorType) {
+            if (elm instanceof TypeElement && ((TypeElement) elm).asType().getKind() == TypeKind.ERROR) {
                 currentPath = null; // Elements not resolved correctly
             }
         }
diff --git a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/EvaluatorTest.java b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/EvaluatorTest.java
index 30e22ec58..43e3481c7 100644
--- a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/EvaluatorTest.java
+++ b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/EvaluatorTest.java
@@ -23,6 +23,7 @@
 import com.sun.jdi.StringReference;
 import com.sun.jdi.Value;
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.ArrayList;
@@ -30,8 +31,16 @@
 import junit.framework.AssertionFailedError;
 import junit.framework.Test;
 import org.netbeans.api.debugger.DebuggerManager;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ui.OpenProjects;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.debugger.jpda.expr.JDIVariable;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
 
 /**
  * Tests evaluation of various expressions.
@@ -58,6 +67,15 @@ public static Test suite() {
     
     protected void setUp () throws Exception {
         super.setUp ();
+        //PreferredCCParser is using SourceUtils.isScanInProgress() to modify behavior; ensure indexing is not running.
+        FileObject prjRoot = FileUtil.toFileObject(new File(System.getProperty("test.dir.src")));
+        assertNotNull(prjRoot);
+        Project prj = FileOwnerQuery.getOwner(prjRoot);
+        assertNotNull(prj);
+        Project annotationsPrj = FileOwnerQuery.getOwner(prj.getProjectDirectory().getParent().getFileObject("api.annotations.common"));
+        assertNotNull(annotationsPrj);
+        OpenProjects.getDefault().open(new Project[] {annotationsPrj}, false);
+        JavaSource.create(ClasspathInfo.create(ClassPath.EMPTY, ClassPath.EMPTY, ClassPath.EMPTY)).runWhenScanFinished(p -> {}, true).get();
         System.setProperty("debugger.evaluator2", "true");
         JPDASupport.removeAllBreakpoints ();
         Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src")+
diff --git a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java
index 23e70f5af..b13a30a6f 100644
--- a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java
+++ b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java
@@ -46,6 +46,8 @@
 import org.netbeans.junit.NbModuleSuite.Configuration;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
 
 /**
  * Contains support functionality for unit tests.
@@ -82,7 +84,25 @@ private JPDASupport (JPDADebugger jpdaDebugger) {
     
     public static Test createTestSuite(Class<? extends TestCase> clazz) {
         Configuration suiteConfiguration = NbModuleSuite.createConfiguration(clazz);
-        suiteConfiguration = suiteConfiguration.gui(false);
+        suiteConfiguration = suiteConfiguration.clusters(".*").enableModules(".*java.source.*").gui(false);
+        if (!(ClassLoader.getSystemClassLoader() instanceof URLClassLoader)) {
+            //when running on JDK 9+, to make the com.sun.jdi package dependency work, we need to make getPackage("com.sun.jdi") work
+            //for system CL's parent (which otherwise happily loads the VirtualMachineManager class,
+            //but won't return the package from getPackage due to JDK "specialty":
+            suiteConfiguration = suiteConfiguration.parentClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
+                @Override
+                protected Package getPackage(String pack) {
+                    if ("com.sun.jdi".equals(pack)) {
+                        try {
+                            return loadClass("com.sun.jdi.VirtualMachineManager").getPackage();
+                        } catch (ClassNotFoundException ex) {
+                            throw new IllegalStateException(ex);
+                        }
+                    }
+                    return super.getPackage(pack);
+                }
+            });
+        }
         //suiteConfiguration = suiteConfiguration.reuseUserDir(false);
         return NbModuleSuite.create(suiteConfiguration);
     }
@@ -134,22 +154,6 @@ public static Test createTestSuite(Class<? extends TestCase> clazz) {
 //        return new JPDASupport (jpdaDebugger);
 //    }
 
-    private static void deleteUserDir() {
-        String userDir = System.getProperty("netbeans.user");
-        if (userDir != null) {
-            delete(new File(userDir));
-        }
-    }
-    
-    private static void delete(File f) {
-        if (f.isDirectory()) {
-            for (File cf : f.listFiles()) {
-                delete(cf);
-            }
-        }
-        f.delete();
-    }
-
     public static JPDASupport attach (String mainClass) throws IOException, 
     DebuggerStartException {
         return attach(mainClass, null);
@@ -241,7 +245,6 @@ public void doFinish () {
         debuggerEngine.getActionsManager ().
             doAction (ActionsManager.ACTION_KILL);
         waitState (JPDADebugger.STATE_DISCONNECTED);
-        deleteUserDir();
     }
 
     public void waitState (int state) {
diff --git a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
index d520076ef..b1d899537 100644
--- a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
+++ b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
@@ -846,7 +846,7 @@ public static Class testMember6() {
     }
     
     public static int testMember7() {
-        // return pointObject.x;
+        // return-TODO pointObject.x;
         return ((java.awt.Point) pointObject).x;
     }
     
@@ -1120,6 +1120,10 @@ public String testClassFieldReference4() {
         return super.basedField;
     }
     
+    public long testLambdas() {
+        return Arrays.stream(new String[] {"a", "b"}).map(str -> str.length()).distinct().count();
+    }
+
     // Private access
     
     // Test public class first
diff --git a/nbjunit/apichanges.xml b/nbjunit/apichanges.xml
index fb563af1f..ab04d99a9 100644
--- a/nbjunit/apichanges.xml
+++ b/nbjunit/apichanges.xml
@@ -34,6 +34,20 @@
     <!-- ACTUAL CHANGES BEGIN HERE: -->
 
 <changes>
+    <change id="NbModuleSuite.Configuration.parentClassLoader">
+        <api name="nbjunit"/>
+        <summary>NbModuleSuite.Configuration.parentClassLoader()</summary>
+        <version major="1" minor="91"/>
+        <date day="17" month="6" year="2018"/>
+        <author login="jlahoda"/>
+        <compatibility addition="yes"/>
+        <description>
+            <p>
+                Adding a way to set parent classloader on which the NB platform should start.
+            </p>
+        </description>
+        <class package="org.netbeans.junit" name="NbModuleSuite"/>
+    </change>
     <change id="branding.token">
         <api name="nbjunit"/>
         <summary>System property branding.token</summary>
diff --git a/nbjunit/manifest.mf b/nbjunit/manifest.mf
index 953464f39..00b5bba1f 100644
--- a/nbjunit/manifest.mf
+++ b/nbjunit/manifest.mf
@@ -1,5 +1,5 @@
 Manifest-Version: 1.0
 OpenIDE-Module: org.netbeans.modules.nbjunit/1
 OpenIDE-Module-Localizing-Bundle: org/netbeans/junit/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.90
+OpenIDE-Module-Specification-Version: 1.91
 
diff --git a/nbjunit/src/org/netbeans/junit/NbModuleSuite.java b/nbjunit/src/org/netbeans/junit/NbModuleSuite.java
index 311171d22..696ed77b5 100644
--- a/nbjunit/src/org/netbeans/junit/NbModuleSuite.java
+++ b/nbjunit/src/org/netbeans/junit/NbModuleSuite.java
@@ -507,6 +507,19 @@ public Configuration reuseUserDir(boolean reuse) {
             ,honorAutoEager, failOnMessage, failOnException, hideExtraModules);
         }
 
+        /**
+         * Sets the parent ClassLoader on which the NB platform should start.
+         * @param parentCL the parent ClassLoader
+         * @return clone of this configuration with the parent ClassLoader set
+         * @since 1.91
+         */
+        public Configuration parentClassLoader(ClassLoader parentCL) {
+            return new Configuration(
+                clusterRegExp, moduleRegExp, startupArgs, parentCL, tests,
+                latestTestCaseClass, reuseUserDir, gui, enableClasspathModules
+            ,honorAutoEager, failOnMessage, failOnException, hideExtraModules);
+        }
+
         /**
          * Creates a test suite from this configuration.
          * Same as {@link #create(org.netbeans.junit.NbModuleSuite.Configuration)} but more fluid.


 

----------------------------------------------------------------
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