Commits

Anonymous committed 2134567

Use standard JDK7 javac

Comments (0)

Files changed (6)

analysis/example/nbproject/build-impl.xml

             </sequential>
         </macrodef>
     </target>
-    <target if="${junit.available}" name="-init-macrodef-junit-debug">
+    <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
         <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
-            <attribute default="${main.class}" name="testClass"/>
-            <attribute default="" name="testMethod"/>
-            <element name="customize2" optional="true"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
             <sequential>
-                <property location="${build.test.results.dir}/TEST-@{testClass}.xml" name="test.report.file"/>
-                <delete file="${test.report.file}"/>
-                <mkdir dir="${build.test.results.dir}"/>
-                <condition else="" property="junit.methods.arg" value="methods=@{testMethod}">
-                    <isset property="test.method"/>
-                </condition>
-                <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
-                    <customize>
-                        <arg value="@{testClass}"/>
-                        <arg value="${junit.methods.arg}"/>
-                        <arg value="showoutput=true"/>
-                        <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
-                        <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
-                        <customize2/>
-                    </customize>
-                </j2seproject3:debug>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
             </sequential>
         </macrodef>
     </target>
-    <target depends="-init-macrodef-junit-debug" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
+    <target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
         <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
-            <attribute default="${main.class}" name="testClass"/>
-            <attribute default="" name="testMethod"/>
-            <element implicit="true" name="customize2" optional="true"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
             <sequential>
-                <j2seproject3:junit-debug testClass="@{testClass}" testMethod="@{testMethod}">
-                    <customize2/>
+                <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
                 </j2seproject3:junit-debug>
             </sequential>
         </macrodef>
         </macrodef>
     </target>
     <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
-        <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+        <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
             <attribute default="${main.class}" name="testClass"/>
             <attribute default="" name="testMethod"/>
             <element implicit="true" name="customize2" optional="true"/>
             </sequential>
         </macrodef>
     </target>
-    <target depends="-init-macrodef-junit-debug-impl,-init-macrodef-testng-debug-impl" name="-init-macrodef-test-debug">
+    <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
         <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
             <attribute default="${main.class}" name="testClass"/>
             <attribute default="" name="testMethod"/>
             <sequential>
-                <j2seproject3:test-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
+                <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${run.jvmargs}"/>
+                        <jvmarg line="${run.jvmargs.ide}"/>
+                    </customize>
+                </j2seproject3:test-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
                     <customize2>
                         <syspropertyset>
                             <propertyref prefix="test-sys-prop."/>
                             <mapper from="test-sys-prop.*" to="*" type="glob"/>
                         </syspropertyset>
                     </customize2>
-                </j2seproject3:test-debug-impl>
+                </j2seproject3:testng-debug-impl>
             </sequential>
         </macrodef>
     </target>
+    <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
     <!--
                 pre NB7.2 profiling section; consider it deprecated
             -->
                 TEST DEBUGGING SECTION
                 =======================
             -->
-    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
         <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
-        <j2seproject3:test-debug testClass="${test.class}"/>
+        <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
     </target>
-    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test-method">
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
         <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
-        <j2seproject3:test-debug testClass="${test.class}" testMethod="${test.method}"/>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
     </target>
     <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
         <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>

analysis/example/nbproject/genfiles.properties

 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=7154a2b6
-nbproject/build-impl.xml.script.CRC32=f408de9d
-nbproject/build-impl.xml.stylesheet.CRC32=c5898323@1.53.0.46
+nbproject/build-impl.xml.script.CRC32=0b24c15b
+nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.54.0.46

analysis/nbproject/project.properties

 jar.index=${jnlp.enabled}
 javac.classpath=\
     ${file.reference.org-openide-util-lookup.jar}:\
-    ${libs.javac.classpath}:\
-    ${libs.nbjavac-lib.classpath}
+    ${libs.javac.classpath}
 # Space-separated list of extra javac options
 javac.compilerargs=
 javac.deprecation=false
 # Space-separated list of JVM arguments used when running the project.
 # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
 # To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=
+run.jvmargs=-Xbootclasspath/p:${libs.javac.classpath}
 run.test.classpath=\
     ${javac.test.classpath}:\
     ${build.test.classes.dir}

analysis/src/j1/tutorial/javac/analysis/api/AnalysisContext.java

 package j1.tutorial.javac.analysis.api;
 
 import com.sun.source.tree.AnnotationTree;
+import com.sun.source.tree.CatchTree;
+import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.ExpressionTree;
 import com.sun.source.tree.ImportTree;
 import com.sun.source.tree.LineMap;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.ParameterizedTypeTree;
+import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TreeVisitor;
 import com.sun.source.util.JavacTask;
+import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
 import com.sun.source.util.Trees;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCNewClass;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
 import java.util.List;
 import javax.annotation.processing.Messager;
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ErrorType;
+import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
 import javax.tools.Diagnostic.Kind;
     private final Messager messager;
     
     public AnalysisContext(CompilationTask task) {
-        this.trees = Trees.instance(task);
+        this.trees = new EnhancedTrees(Trees.instance(task));
         this.elements = ((JavacTask) task).getElements();
         this.types = ((JavacTask) task).getTypes();
         this.messager = new MessagerImpl(trees);
     }
     
     public AnalysisContext(ProcessingEnvironment processingEnvironment) {
-        this.trees = Trees.instance(processingEnvironment);
+        this.trees = new EnhancedTrees(Trees.instance(processingEnvironment));
         this.elements = processingEnvironment.getElementUtils();
         this.types = processingEnvironment.getTypeUtils();
         this.messager = processingEnvironment.getMessager();
         }
     }
     
+    private static final class EnhancedTrees extends Trees {
+        private final Trees delegate;
+
+        public EnhancedTrees(Trees delegate) {
+            this.delegate = delegate;
+        }
+
+        @Override
+        public SourcePositions getSourcePositions() {
+            return delegate.getSourcePositions();
+        }
+
+        @Override
+        public Tree getTree(Element elmnt) {
+            return delegate.getTree(elmnt);
+        }
+
+        @Override
+        public ClassTree getTree(TypeElement te) {
+            return delegate.getTree(te);
+        }
+
+        @Override
+        public MethodTree getTree(ExecutableElement ee) {
+            return delegate.getTree(ee);
+        }
+
+        @Override
+        public Tree getTree(Element elmnt, AnnotationMirror am) {
+            return delegate.getTree(elmnt, am);
+        }
+
+        @Override
+        public Tree getTree(Element elmnt, AnnotationMirror am, AnnotationValue av) {
+            return delegate.getTree(elmnt, am, av);
+        }
+
+        @Override
+        public TreePath getPath(CompilationUnitTree cut, Tree tree) {
+            return delegate.getPath(cut, tree);
+        }
+
+        @Override
+        public TreePath getPath(Element elmnt) {
+            return delegate.getPath(elmnt);
+        }
+
+        @Override
+        public TreePath getPath(Element elmnt, AnnotationMirror am) {
+            return delegate.getPath(elmnt, am);
+        }
+
+        @Override
+        public TreePath getPath(Element elmnt, AnnotationMirror am, AnnotationValue av) {
+            return delegate.getPath(elmnt, am, av);
+        }
+
+        private Element elementFor(Tree tree) {
+            switch (tree.getKind()) {
+                case COMPILATION_UNIT:
+                    return ((JCCompilationUnit) tree).packge;
+                case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE:
+                    return ((JCClassDecl) tree).sym;
+                case METHOD:
+                    return ((JCMethodDecl) tree).sym;
+                case VARIABLE:
+                    return ((JCVariableDecl) tree).sym;
+                case IDENTIFIER:
+                    return ((JCIdent) tree).sym;
+                case MEMBER_SELECT:
+                    return ((JCFieldAccess) tree).sym;
+                case NEW_CLASS:
+                    return ((JCNewClass) tree).constructor;
+                case METHOD_INVOCATION:
+                    return elementFor(((MethodInvocationTree) tree).getMethodSelect());
+                case PARAMETERIZED_TYPE:
+                    return elementFor(((ParameterizedTypeTree) tree).getType());
+                case ANNOTATION:
+                case TYPE_PARAMETER:
+                    if (((JCTree) tree).type != null)
+                        return ((JCTree) tree).type.tsym;
+            }
+            
+            return null;
+        }
+        
+        @Override
+        public Element getElement(TreePath tp) {
+            return elementFor(tp.getLeaf());
+        }
+
+        @Override
+        public TypeMirror getTypeMirror(TreePath tp) {
+            return delegate.getTypeMirror(tp);
+        }
+
+        @Override
+        public Scope getScope(TreePath tp) {
+            return delegate.getScope(tp);
+        }
+
+        @Override
+        public String getDocComment(TreePath tp) {
+            return delegate.getDocComment(tp);
+        }
+
+        @Override
+        public boolean isAccessible(Scope scope, TypeElement te) {
+            return delegate.isAccessible(scope, te);
+        }
+
+        @Override
+        public boolean isAccessible(Scope scope, Element elmnt, DeclaredType dt) {
+            return delegate.isAccessible(scope, elmnt, dt);
+        }
+
+        @Override
+        public TypeMirror getOriginalType(ErrorType et) {
+            return delegate.getOriginalType(et);
+        }
+
+        @Override
+        public void printMessage(Kind kind, CharSequence cs, Tree tree, CompilationUnitTree cut) {
+            delegate.printMessage(kind, cs, tree, cut);
+        }
+
+        @Override
+        public TypeMirror getLub(CatchTree ct) {
+            return delegate.getLub(ct);
+        }
+        
+    }
+    
 }

Binary file added.

lib/nblibraries.properties

 libs.CopyLibs.displayName=CopyLibs Task
 libs.CopyLibs.prop-version=1.0
 libs.javac.classpath=\
-    ${base}/nb-javac-api.jar:\
-    ${base}/nb-javac-impl.jar
+    ${base}/javac-jdk7.jar
 libs.javac.displayName=javac
 libs.nbjavac-lib.classpath=\
     ${base}/org-netbeans-lib-nbjavac.jar
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.