Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cofoja fails to build with Java 10 #52

Open
ebourg opened this issue May 16, 2018 · 2 comments
Open

Cofoja fails to build with Java 10 #52

ebourg opened this issue May 16, 2018 · 2 comments

Comments

@ebourg
Copy link

ebourg commented May 16, 2018

Hi,

I get the following compilation errors with Java 10:

build:
    [mkdir] Created dir: cofoja/obj/bare
   [ujavac] Compiling 86 source files to cofoja/obj/bare
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:20: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.AnnotationTree;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:21: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.AssignmentTree;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:22: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.CompilationUnitTree;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:23: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.ExpressionTree;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:24: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.ImportTree;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:25: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.LineMap;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:26: error: package com.sun.source.tree does not exist
   [ujavac] import com.sun.source.tree.NewArrayTree;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:27: error: package com.sun.source.tree.Tree does not exist
   [ujavac] import com.sun.source.tree.Tree.Kind;
   [ujavac]                                ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:28: error: package com.sun.source.util does not exist
   [ujavac] import com.sun.source.util.SourcePositions;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:29: error: package com.sun.source.util does not exist
   [ujavac] import com.sun.source.util.TreePath;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:30: error: package com.sun.source.util does not exist
   [ujavac] import com.sun.source.util.Trees;
   [ujavac]                           ^
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:61: error: cannot find symbol
   [ujavac]     Trees treeUtils = Trees.instance(processingEnv);
   [ujavac]     ^
   [ujavac]   symbol:   class Trees
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:61: error: cannot find symbol
   [ujavac]     Trees treeUtils = Trees.instance(processingEnv);
   [ujavac]                       ^
   [ujavac]   symbol:   variable Trees
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:66: error: cannot find symbol
   [ujavac]     TreePath path = treeUtils.getPath(element, annotation);
   [ujavac]     ^
   [ujavac]   symbol:   class TreePath
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:71: error: cannot find symbol
   [ujavac]     CompilationUnitTree unitTree = path.getCompilationUnit();
   [ujavac]     ^
   [ujavac]   symbol:   class CompilationUnitTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:72: error: cannot find symbol
   [ujavac]     LineMap lineMap = unitTree.getLineMap();
   [ujavac]     ^
   [ujavac]   symbol:   class LineMap
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:73: error: cannot find symbol
   [ujavac]     SourcePositions positions = treeUtils.getSourcePositions();
   [ujavac]     ^
   [ujavac]   symbol:   class SourcePositions
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:75: error: cannot find symbol
   [ujavac]     AnnotationTree annotationTree = (AnnotationTree) path.getLeaf();
   [ujavac]     ^
   [ujavac]   symbol:   class AnnotationTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:75: error: cannot find symbol
   [ujavac]     AnnotationTree annotationTree = (AnnotationTree) path.getLeaf();
   [ujavac]                                      ^
   [ujavac]   symbol:   class AnnotationTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:76: error: cannot find symbol
   [ujavac]     AssignmentTree assignTree =
   [ujavac]     ^
   [ujavac]   symbol:   class AssignmentTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:77: error: cannot find symbol
   [ujavac]         (AssignmentTree) annotationTree.getArguments().get(0);
   [ujavac]          ^
   [ujavac]   symbol:   class AssignmentTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:78: error: cannot find symbol
   [ujavac]     ExpressionTree exprTree = assignTree.getExpression();
   [ujavac]     ^
   [ujavac]   symbol:   class ExpressionTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:81: error: cannot find symbol
   [ujavac]     if (exprTree.getKind() == Kind.STRING_LITERAL) {
   [ujavac]                               ^
   [ujavac]   symbol:   variable Kind
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:85: error: cannot find symbol
   [ujavac]       NewArrayTree valuesTree = (NewArrayTree) exprTree;
   [ujavac]       ^
   [ujavac]   symbol:   class NewArrayTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:85: error: cannot find symbol
   [ujavac]       NewArrayTree valuesTree = (NewArrayTree) exprTree;
   [ujavac]                                  ^
   [ujavac]   symbol:   class NewArrayTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:86: error: cannot find symbol
   [ujavac]       for (ExpressionTree valueTree : valuesTree.getInitializers()) {
   [ujavac]            ^
   [ujavac]   symbol:   class ExpressionTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:106: error: cannot find symbol
   [ujavac]     Trees treeUtils = Trees.instance(processingEnv);
   [ujavac]     ^
   [ujavac]   symbol:   class Trees
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:106: error: cannot find symbol
   [ujavac]     Trees treeUtils = Trees.instance(processingEnv);
   [ujavac]                       ^
   [ujavac]   symbol:   variable Trees
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:111: error: cannot find symbol
   [ujavac]     TreePath path = treeUtils.getPath(element);
   [ujavac]     ^
   [ujavac]   symbol:   class TreePath
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:116: error: cannot find symbol
   [ujavac]     CompilationUnitTree unitTree = path.getCompilationUnit();
   [ujavac]     ^
   [ujavac]   symbol:   class CompilationUnitTree
   [ujavac]   location: class JavacUtils
   [ujavac] cofoja/src/com/google/java/contract/core/apt/JavacUtils.java:119: error: cannot find symbol
   [ujavac]     for (ImportTree importTree : unitTree.getImports()) {
   [ujavac]          ^
   [ujavac]   symbol:   class ImportTree
   [ujavac]   location: class JavacUtils
   [ujavac] Note: cofoja/src/com/google/java/contract/core/agent/ContractFixingClassAdapter.java uses or overrides a deprecated API.
   [ujavac] Note: Recompile with -Xlint:deprecation for details.
   [ujavac] Note: cofoja/src/com/google/java/contract/util/Predicates.java uses unchecked or unsafe operations.
   [ujavac] Note: Recompile with -Xlint:unchecked for details.
   [ujavac] 31 errors
@ghost
Copy link

ghost commented May 16, 2018

Your missing classes are, for as far as I can see after a quick look, (almost) all in what used to be tools.jar. For that, see the Migration Guide documentation for Java 10:

"Removed rt.jar and tools.jar
Class and resource files previously stored in lib/rt.jar, lib/tools.jar, lib/dt.jar and various other internal JAR files are stored in a more efficient format in implementation-specific files in the lib directory
"

Browse it here: https://docs.oracle.com/javase/10/migrate/toc.htm#JSMIG-GUID-A78CC891-701D-4549-AA4E-B8DD90228B4B

@miasma
Copy link

miasma commented Sep 14, 2018

Maybe this is not a problem with Java 10 anymore? I also ran into some issues with old ASM version, but the 6.x releases should support Java 10. I used these steps to successfully build cofoja (ASM 6.x release versions are split into multiple jars, so changed the build/ivy files):

$ java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13)
OpenJDK 64-Bit Server VM (build 10.0.2+13, mixed mode)

diff --git a/build.xml b/build.xml
index 67a678a..e7df37a 100644
--- a/build.xml
+++ b/build.xml
@@ -177,11 +177,14 @@
                  provider="${apt.class}" />
         <zipfileset includes="**/*.class"
                     src="@{barejarfile}" />
+        <!--
         <zipfileset includes="**/*.class">
           <fileset dir="${lib.dir}">
             <include name="asm-*.jar" />
           </fileset>
         </zipfileset>
+        -->
+        <zipgroupfileset includes="**/*.jar" dir="${lib.dir}" />
       </jar>
     </sequential>
   </macrodef>
diff --git a/ivy.xml b/ivy.xml
index d029264..ab2cb07 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -12,7 +12,9 @@
     <artifact name="cofoja+contracts" conf="contracts" />
   </publications>
   <dependencies>
-    <dependency org="org.ow2.asm" name="asm-all" rev="6.+" conf="*->default" />
+    <dependency org="org.ow2.asm" name="asm-commons" rev="6.2.1" conf="*->default" />
+    <dependency org="org.ow2.asm" name="asm-tree" rev="6.2.1" conf="*->default" />
+    <dependency org="org.ow2.asm" name="asm" rev="6.2.1" conf="*->default" />
     <dependency org="junit" name="junit-dep" rev="[3.8,)" conf="test->default" />
   </dependencies>
 </ivy-module>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants