I encountered an issue, similar to the #2412 issue. On startup I get the following warning:
Unknown asm implementation version, assuming version 393216
Annotation scanning works fine, because it defaults to the correct version.
I tried various things recommended in the above mentioned #2412 issue. I ran @joakime class for detecting multiple ASM implementations WhereIsThisComingFrom and it detects only one version. I also ran the @janbartel class which runs embedded server and I get the same warning.
Warning comes from the following lines in AnnotationParser class:
String s = asm.getImplementationVersion();
if (s == null) {
LOG.warn("Unknown asm implementation version, assuming version {}", new Object[]{asmVersion});
}
I have been experimenting with the following program and only asm dependency on the classpath:
public static void main(String[] args) {
Package asm = Opcodes.class.getPackage();
System.out.println(Opcodes.class.getPackage().getImplementationVersion());
}
Version 6.0 of the library works fine, anything above (6.1, 6.1.1, 6.2, 6.2.1) returns null. The Opcodes.class.getPackage() invocation suggested in the previous issue doesn't make a difference. In transition from 6.0 to 6.1 the asm library switched from Ant build to Gradle, which may cause this issue. I inspected the MANIFEST.MF files from Maven central asm libraries.
This is the content of MANIFEST.MF for asm __6.0__:
Manifest-Version: 1.0
Bnd-LastModified: 1506148153920
Bundle-DocURL: http://asm.objectweb.org
Bundle-ManifestVersion: 2
Bundle-Name: ASM
Bundle-RequiredExecutionEnvironment: J2SE-1.3
Bundle-SymbolicName: org.objectweb.asm
Bundle-Vendor: France Telecom R&D
Bundle-Version: 6.0
Created-By: 1.8.0_131 (Oracle Corporation)
Export-Package: org.objectweb.asm;version="6.0",org.objectweb.asm.sign
ature;version="6.0"
Implementation-Title: ASM
Implementation-Vendor: France Telecom R&D
Implementation-Version: 6.0
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.5))"
Tool: Bnd-3.2.0.201605172007
This is the content of MANIFEST.MF for asm __6.2.1__:
Manifest-Version: 1.0
Bundle-DocURL: http://asm.ow2.org
Bundle-ManifestVersion: 2
Bundle-Name: org.objectweb.asm
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-SymbolicName: org.objectweb.asm
Bundle-Version: 6.2.1
Export-Package: org.objectweb.asm;version="6.2.1",org.objectweb.asm.si
gnature;version="6.2.1"
Implementation-Title: ASM, a very small and fast Java bytecode manipul
ation framework
Notice that Implementation-Version property is missing in the newer versions.
All tests were run on Linux using OpenJDK 1.8.0_181. I also encountered warning with JRE 10.0.2+13 running on Linux and JRE 1.8.0_162-b12 running on Windows.
Jetty version: 9.4.11.v20180605
@urbim good investigation. Sounds like you should raise an issue over on the asm project to fix their build.
Thanks for the response.
I opened an issue at their end. Meanwhile, is there anything you can do to at least suppress the warning until the build gets fixed for the asm library. I'm guessing I'm not the only one with this bug since this was introduced with Jetty version 9.4.10.v20180503. And I can't really go back since the annotation scanning doesn't work in Java 10 if I use asm version 6.0.
As you've said, annotation scanning works fine, can you explain what the problem is with having this warning message in the log?
The problem is that our users will see the warning each time their server starts up and wonder what it is.
I can understand why you don't want to disable the warning, I was just wondering if there was an elegant solution like logging the warning only if problems occur during annotation scanning.
I guess we will keep the warning until the proper fix gets propagated.
Looks like asm fixed this in master and I imagine they released a fix in 6.2.2 but won't the 6.1, 6.1.1, 6.2 jars will give this message which is pretty cryptic (where does 393216 come from)? Can the Bundle-Version be a fallback?
It's too difficult to get the Bundle-Version. I can think of 2 options, tell me which you prefer:
I think I prefer 2 but I will defer to others if someone has a strong opinion
Future pointed out by @forax on asm issue https://gitlab.ow2.org/asm/asm/issues/317847#note_38840 ...
BTW, since Java 9 the way to get the implementation version is to use the Module version,
System.out.println(Opcodes.class.getModule().getDescriptor().rawVersion());
Including it here for reference at a later point.
Also, because it shows a JPMS module with a version string.
We could dive into the Manifest parsing for Bundle-Version if Implementation-Version isn't present.
But I don't think that's necessary, as (to me) Unknown asm implementation version, assuming version 393216 tells me that we found a ASM6 version at least
Because of the magic number 393216, which comes from Opcodes.ASM6.
Why do we care about the version number? It's because we want to ensure that the minimum version of ASM6 is present, too many people are still using older, incompatible versions of asm with Jetty.
That magic number btw, has the following meaning (from the asm codebase) ...
public interface Opcodes {
// ASM API versions.
int ASM4 = 4 << 16 | 0 << 8;
int ASM5 = 5 << 16 | 0 << 8;
int ASM6 = 6 << 16 | 0 << 8;
Guess we could validate that magic number as well
I'm thinking of making the specific case where there is no implementation version an INFO, but leaving every other case a WARN (no Package, version number other than 4,5,6).
If there are no objections in the next day then I'll do that.
I'll also make all the log statements print out "ASM6" instead of the int value.
Closing, PR merged.
Most helpful comment
Thanks for the response.
I opened an issue at their end. Meanwhile, is there anything you can do to at least suppress the warning until the build gets fixed for the asm library. I'm guessing I'm not the only one with this bug since this was introduced with Jetty version
9.4.10.v20180503. And I can't really go back since the annotation scanning doesn't work in Java 10 if I use asm version6.0.