Community
Participate
Working Groups
Created attachment 283612 [details] LTW java 14 asm fails on readConst I recently upgraded my tycho project to java 14. I use LTWeaving in my integration tests to simulate corner or error cases. After upgrade to java 14 target when running test by tycho-surefire-plugin with aspectjweaver as my agent I get below error: AspectJ Internal Error: unable to add stackmap attributes. null java.lang.IllegalArgumentException at aj.org.objectweb.asm.ClassReader.readConst(ClassReader.java:3617) at aj.org.objectweb.asm.ClassReader.readCode(ClassReader.java:2193) at aj.org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1284) at aj.org.objectweb.asm.ClassReader.accept(ClassReader.java:688) at aj.org.objectweb.asm.ClassReader.accept(ClassReader.java:400) at org.aspectj.weaver.bcel.asm.StackMapAdder.addStackMaps(StackMapAdder.java:45) Debuging tells me that it fails in context of constructor of attached class that is supposed to be weaved. I tried also this version https://repo.spring.io/snapshot/org/aspectj/aspectjweaver/1.9.6.BUILD-SNAPSHOT/ with the same results. Do java 14 is not yet supported at all even if I do not use java 14 specific syntax?
Hey - you will need 1.9.6 for Java14. The latest snapshot is 1.9.6.BUILD-SNAPSHOT which is in the Spring repo: <repository> <id>snapshots</id> <name>snapshots</name> <url>https://repo.spring.io/snapshot</url> </repository> I was waiting for a bit of extra feedback on a particular issue before formally releasing it but I think I've waited long enough so I'll do the release soon.
Although I see the end of your comment says you tried it, interesting.
Possibly the ASM that is being used isn't recent enough (see the stacktrace is mentioning the shaded copy of asm included in AspectJ). Maybe it is lucky I haven't done the full release :) I'll see what version we are on of that library and see if I can update it.
Created attachment 283616 [details] dumb1
Created attachment 283617 [details] dump2
Created attachment 283618 [details] dump3
Created attachment 283619 [details] dump4
Created attachment 283620 [details] dump5
Created attachment 283621 [details] dump6
I attached files that are being generated when I run tests. Before upgrade those files haven't been generated. The error in one file: org.aspectj.weaver.BCException: Unable to find Asm for stackmap generation (Looking for 'aj.org.objectweb.asm.ClassReader'). Stackmap generation for woven code is required to avoid verify errors on a Java 1.7 or higher runtime I see also in the console but after the first one mentioned in the first message. I assume that "Unable to find Asm for stackmap" is a consequence of the first. I don't see information in stack about asm being used. I will debug so I can confirm the version. Seeing pom.xml of weaver I suppose that we expect version 7.2: <dependency> <groupId>asm</groupId> <artifactId>asm</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/../lib/asm/asm-7.2.renamed.jar</systemPath> </dependency>
From: https://asm.ow2.io/versions.html I see that version 7.3.1 introduced "new V15 constant". Maybe related as my exception is on "readConst".
I upgraded from 7.2 asm to 8.0 - and published a 1.9.6.BUILD-SNAPSHOT that is worth trying I think.
The same problem still persists with the same stack. Dumps file shows that I do use the new version: ---- AspectJ Properties --- AspectJ Compiler 1.9.6.BUILD-SNAPSHOT built on Thursday Jul 16, 2020 at 12:52:30 PDT I will try to use asm library to directly to parse my code
Created attachment 283638 [details] Class being parsed when error happen Class being parsed
Created attachment 283639 [details] Jar needed on classpath to parse class
I am able to parse constructor even withasm 7.0: ALOAD 0 INVOKESPECIAL org/eclipse/ui/wizards/newresource/BasicNewProjectResourceWizard.<init> ()V RETURN I am not sure if I do it correctly. I am attaching groovy script with code from stackoverflow: https://stackoverflow.com/questions/7984003/pretty-printing-a-method-in-asm-bytecode
Created attachment 283640 [details] parse method groovy script groovy -cp org.eclipse.equinox.common_3.12.0.v20200504-1602.jar asm.groovy CreateProjectWizard.class
I tried using directly aspectjweaver and I can parse class (no error): @Grab(group='org.aspectj', module='aspectjweaver', version='1.9.5') import aj.org.objectweb.asm.ClassReader; import aj.org.objectweb.asm.ClassVisitor; import aj.org.objectweb.asm.ClassWriter; import org.aspectj.weaver.bcel.BcelWorld import org.aspectj.weaver.bcel.asm.StackMapAdder.AspectJClassVisitor; import org.aspectj.weaver.bcel.asm.StackMapAdder.AspectJConnectClassWriter; FileInputStream is = new FileInputStream(args[0]) ClassReader cr = new ClassReader(is) ClassWriter cw = new AspectJConnectClassWriter(cr, new BcelWorld(args[1])) ClassVisitor cv = new AspectJClassVisitor(cw) cr.accept(cv, 0) println cw.toByteArray() groovy asm-aj.groovy CreateProjectWizard.class org.eclipse.equinox.common_3.12.0.v20200504-1602.jar Does the sate of BcelWorld depends on something more I should try to reproduce the issue?
There was one additional information that I should have been mentioned and it looks this is the reason of error. Together with aspecjweaver agent I am using also jacoco agent and jacoco is preceding aspectj. Jacoco is on version 8.5.0 that officially is not supporting java 14. Removing jacoco agent error doesn't appear. I guess you can close the issue. Thanks!
Just for info. I tried pair with jacoco snapshot agent org.jacoco.agent-0.8.6-20200717.014125-68-runtime.jar: https://www.jacoco.org/jacoco/trunk/doc/changes.html The problem exists. It looks like they also use ASM 8.0.1.