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

ap-loader-all in maven not the same as the released #7

Open
maxandersen opened this issue Feb 14, 2023 · 4 comments
Open

ap-loader-all in maven not the same as the released #7

maxandersen opened this issue Feb 14, 2023 · 4 comments

Comments

@maxandersen
Copy link
Contributor

I've been trying to use ap-loader-* artifacts from maven but afaics the released jar's from github release page and the maven central jars are NOT the same.

Resulting in this error using the maven jars:

run: /Users/manderse/.jbang/cache/jdks/19/bin/java '-javaagent:/Users/manderse/.m2/repository/me/bechberger/ap-loader-macos/2.9-4/ap-loader-macos-2.9-4.jar=start,event=cpu,file=profile.html' --enable-preview --add-opens java.base/java.lang=ALL-UNNAMED -classpath /Users/manderse/.jbang/cache/jars/VirtualThreadReflectionBenchmark.java.7d632a1c2e33734f11f5a17bf40fd430f897bd02269d088fa6ed26853056da8b.jar:/Users/manderse/.m2/repository/org/openjdk/jmh/jmh-generator-annprocess/1.36/jmh-generator-annprocess-1.36.jar:/Users/manderse/.m2/repository/org/openjdk/jmh/jmh-core/1.36/jmh-core-1.36.jar:/Users/manderse/.m2/repository/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar:/Users/manderse/.m2/repository/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar org.openjdk.jmh.Main
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
Caused by: java.lang.NoClassDefFoundError: dev/dirs/ProjectDirectories
	at one.profiler.AsyncProfilerLoader.getExtractionDirectory(AsyncProfilerLoader.java:128)
	at one.profiler.AsyncProfilerLoader.getAsyncProfilerPath(AsyncProfilerLoader.java:345)
	at one.profiler.AsyncProfilerLoader.attach(AsyncProfilerLoader.java:613)
	at one.profiler.AsyncProfilerLoader.agentmain(AsyncProfilerLoader.java:625)
	at one.profiler.AsyncProfilerLoader.premain(AsyncProfilerLoader.java:586)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	... 3 more
Caused by: java.lang.ClassNotFoundException: dev.dirs.ProjectDirectories
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed

Using the downloaded jar works fine so I tried to compare them and notice that the released jars has dev/dirs embedded but the ones in maven central does not.

2023-02-14_11-37-27

There is also native image config missing and the manifest.mf is slightly different:

2023-02-14_11-38-14

Is there a reason for this difference?

@parttimenerd
Copy link
Member

Both should be different, as the maven package does not contain the project-dir dependency. The JARs from GitHub are usually built from snapshots, then released later on maven central (albeit I release them rather often). Does this help you?

@maxandersen
Copy link
Contributor Author

okey - it just means the ap-loader in maven central can't be used as agent and that the github jar says SNAPSHOT in them.

Thus for the jbang-catalog discussed in #6 I would need to use the github released jar not the maven central one.

@parttimenerd
Copy link
Member

okey - it just means the ap-loader in maven central can't be used as agent and that the github jar says SNAPSHOT in them.

You could use the maven JAR if you put the dependency on the class path.

It might be a bug that the GitHub JAR says SNAPSHOT.

@maxandersen
Copy link
Contributor Author

Javaagent only allows one jar.

And yes, could add to classpath it pollutes the applications classpath.

Second best option is boot classpath but that is a non-public openjdk feature.

So don't really see a way to use the agent unless using the GitHub releases where the necessary dependencies are included.

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

No branches or pull requests

2 participants