nhatminhle / cofoja

Contracts for Java
GNU Lesser General Public License v3.0
153 stars 18 forks source link

Cofoja fails to build with Java 11 #53

Open miasma opened 6 years ago

miasma commented 6 years ago

There's a new problem building Cofoja on Java 11 (probably due to bytecode format changes):

$ ant fetch
...
$ ant build
...
    [mkdir] Created dir: /home/foo/cofoja/obj/tmp0
    [mkdir] Created dir: /home/foo/cofoja/obj/stage0
   [ujavac] Compiling 86 source files to /home/foo/cofoja/obj/tmp0
   [ujavac] Note: Some input files use or override a deprecated API.
   [ujavac] Note: Recompile with -Xlint:deprecation for details.
   [ujavac] Note: /home/foo/cofoja/src/com/google/java/contract/util/Predicates.java uses unchecked or unsafe operations.
   [ujavac] Note: Recompile with -Xlint:unchecked for details.
  [cofojab] Instrumenting 147 class files to /home/foo/cofoja/obj/stage0

BUILD FAILED
/home/foo/cofoja/build.xml:324: The following error occurred while executing this line:
/home/foo/cofoja/build.xml:203: java.lang.instrument.IllegalClassFormatException
    at com.google.java.contract.core.agent.ContractClassFileTransformer.transformWithContracts(ContractClassFileTransformer.java:302)
    at com.google.java.contract.core.agent.PreMain.instrument(PreMain.java:190)
    at PreAgentAntTask.execute(PreAgentAntTask.java:73)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at java.base/java.util.Vector.forEach(Vector.java:1387)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.Target.execute(Target.java:449)
    at org.apache.tools.ant.Target.performTasks(Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:834)
    at org.apache.tools.ant.Main.startAnt(Main.java:223)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.lang.UnsupportedOperationException
    at org.objectweb.asm.ClassVisitor.visitNestHostExperimental(ClassVisitor.java:158)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:541)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)
    at com.google.java.contract.core.agent.ContractClassFileTransformer.extractContracts(ContractClassFileTransformer.java:363)
    at com.google.java.contract.core.agent.ContractClassFileTransformer.transformWithContracts(ContractClassFileTransformer.java:298)
    ... 33 more
nhatminhle commented 6 years ago

What version of ASM are you building with?

Nhat

On Mon, Sep 17, 2018 at 8:22 PM miasma notifications@github.com wrote:

There's a new problem building Cofoja on Java 11 (probably due to bytecode format changes):

$ ant fetch ... $ ant build ... [mkdir] Created dir: /home/foo/cofoja/obj/tmp0 [mkdir] Created dir: /home/foo/cofoja/obj/stage0 [ujavac] Compiling 86 source files to /home/foo/cofoja/obj/tmp0 [ujavac] Note: Some input files use or override a deprecated API. [ujavac] Note: Recompile with -Xlint:deprecation for details. [ujavac] Note: /home/foo/cofoja/src/com/google/java/contract/util/Predicates.java uses unchecked or unsafe operations. [ujavac] Note: Recompile with -Xlint:unchecked for details. [cofojab] Instrumenting 147 class files to /home/foo/cofoja/obj/stage0

BUILD FAILED /home/foo/cofoja/build.xml:324: The following error occurred while executing this line: /home/foo/cofoja/build.xml:203: java.lang.instrument.IllegalClassFormatException at com.google.java.contract.core.agent.ContractClassFileTransformer.transformWithContracts(ContractClassFileTransformer.java:302) at com.google.java.contract.core.agent.PreMain.instrument(PreMain.java:190) at PreAgentAntTask.execute(PreAgentAntTask.java:73) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at java.base/java.util.Vector.forEach(Vector.java:1387) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at org.apache.tools.ant.Target.execute(Target.java:449) at org.apache.tools.ant.Target.performTasks(Target.java:470) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388) at org.apache.tools.ant.Project.executeTarget(Project.java:1361) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.apache.tools.ant.Main.runBuild(Main.java:834) at org.apache.tools.ant.Main.startAnt(Main.java:223) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101) Caused by: java.lang.UnsupportedOperationException at org.objectweb.asm.ClassVisitor.visitNestHostExperimental(ClassVisitor.java:158) at org.objectweb.asm.ClassReader.accept(ClassReader.java:541) at org.objectweb.asm.ClassReader.accept(ClassReader.java:391) at com.google.java.contract.core.agent.ContractClassFileTransformer.extractContracts(ContractClassFileTransformer.java:363) at com.google.java.contract.core.agent.ContractClassFileTransformer.transformWithContracts(ContractClassFileTransformer.java:298) ... 33 more

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nhatminhle/cofoja/issues/53, or mute the thread https://github.com/notifications/unsubscribe-auth/ADtbnktxCv6B3P05FzXkwy2AlSI-IpQkks5ub_ZjgaJpZM4WsjOe .

miasma commented 6 years ago

I used the 6.2.1 (latest atm) with these changes listed here https://github.com/nhatminhle/cofoja/issues/52#issuecomment-421457814

miasma commented 6 years ago

Well let's see. If it's another issue with asm, they'll be releasing 7.0 soonish..

miasma commented 6 years ago

With ASM 7.0-beta-SNAPSHOT I now get ''' stage0: [mkdir] Created dir: /home/foo/cofoja/obj/tmp0 [mkdir] Created dir: /home/foo/cofoja/obj/stage0 [ujavac] Compiling 86 source files to /home/foo/cofoja/obj/tmp0 [ujavac] Note: Some input files use or override a deprecated API. [ujavac] Note: Recompile with -Xlint:deprecation for details. [ujavac] Note: /home/foo/cofoja/src/com/google/java/contract/util/Predicates.java uses unchecked or unsafe operations. [ujavac] Note: Recompile with -Xlint:unchecked for details. [cofojab] Instrumenting 147 class files to /home/foo/cofoja/obj/stage0

BUILD FAILED /home/foo/cofoja/build.xml:324: The following error occurred while executing this line: /home/foo/cofoja/build.xml:203: java.lang.instrument.IllegalClassFormatException at com.google.java.contract.core.agent.ContractClassFileTransformer.transformWithContracts(ContractClassFileTransformer.java:302) at com.google.java.contract.core.agent.PreMain.instrument(PreMain.java:190) at PreAgentAntTask.execute(PreAgentAntTask.java:73) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at java.base/java.util.Vector.forEach(Vector.java:1387) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99) at org.apache.tools.ant.Task.perform(Task.java:350) at org.apache.tools.ant.Target.execute(Target.java:449) at org.apache.tools.ant.Target.performTasks(Target.java:470) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388) at org.apache.tools.ant.Project.executeTarget(Project.java:1361) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.apache.tools.ant.Main.runBuild(Main.java:834) at org.apache.tools.ant.Main.startAnt(Main.java:223) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101) Caused by: java.lang.UnsupportedOperationException: This feature requires ASM7 at org.objectweb.asm.ClassVisitor.visitNestHost(ClassVisitor.java:150) at org.objectweb.asm.ClassReader.accept(ClassReader.java:540) at org.objectweb.asm.ClassReader.accept(ClassReader.java:389) at com.google.java.contract.core.agent.ContractClassFileTransformer.extractContracts(ContractClassFileTransformer.java:363) at com.google.java.contract.core.agent.ContractClassFileTransformer.transformWithContracts(ContractClassFileTransformer.java:298) ... 33 more ''' So the code needs to be changed to use ASM7.

miasma commented 6 years ago

Ok, this seemed to work after switching the ASM5 definitions to ASM7 in the code. Made a PR: https://github.com/nhatminhle/cofoja/pull/54

kuleszdl commented 3 years ago

Thank you a lot for providing this MR @miasma - it worked very well for me with Java 14 (using AdoptOpenJDK).

rolintoucour commented 3 years ago

Is it release possible to release a version with this fix? We are upgrading to Java 15 and cofoja is blocking us