Giter VIP home page Giter VIP logo

Comments (6)

chriswhocodes avatar chriswhocodes commented on June 3, 2024 1
Author: Chris Newland <[email protected]>
Date:   Mon Jan 4 23:05:26 2021 +0000

    Fix JavapTask fallback for JDK17 reflection failure (module system)

Yep, the binary release was on 2020-10-29 so it doesn't include this fix.

I agree my commit was a hack and that the correct module system fix is better.

Let me try your suggestion!

Thanks for reporting and contributing :)

from jitwatch.

chriswhocodes avatar chriswhocodes commented on June 3, 2024 1

image
Bingo! That works :)
I'll commit the pom fix and then after some testing I'll create some new binaries.
Many thanks Thiago!

from jitwatch.

chriswhocodes avatar chriswhocodes commented on June 3, 2024

Hi @Thihup hmm, I put in a catch so that it should fallback to JavapProcess (a ProcessBuilder wrapper around the JDK/bin/javap executable) if the reflection attempt fails.

Please can you let me know what OS and JDK you are using (and are you using the latest JITWatch built from source?)

Cheers,

Chris

from jitwatch.

Thihup avatar Thihup commented on June 3, 2024

Hi @chriswhocodes. I'm using Linux and JDK 18, but since JDK 16 this exception happens.
I'm using the 1.4.0-shaded.jar version, but I can try building it from the source too.

I think if it is possible to add the manifest attribute, it should be a little faster in the JVMs that support that manifest attribute.

from jitwatch.

chriswhocodes avatar chriswhocodes commented on June 3, 2024

OK, I updated the shade plugin config to

<plugin>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-shade-plugin</artifactId>
                                                <version>3.2.0</version>
                                                <executions>
                                                        <execution>
                                                                <phase>package</phase>
                                                                <goals>
                                                                        <goal>shade</goal>
                                                                </goals>
                                                                <configuration>
                                                                        <shadedArtifactAttached>true</shadedArtifactAttached>
                                                                        <shadedClassifierName>project-classifier</shadedClassifierName>
                                                                        <outputFile>target/ui-shaded.jar</outputFile>
                                                                        <transformers>
                                                                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                                                                        <mainClass>${main.class}</mainClass>
                                                                                        <manifestEntries>
                                                                                                <Add-Exports-Private>jdk.jdeps/com.sun.tools.javap</Add-Exports-Private>
                                                                                        </manifestEntries>
                                                                                </transformer>
                                                                        </transformers>
                                                                </configuration>
                                                        </execution>
                                                </executions>
                                        </plugin>

which gives me a MANIFEST.MF of

chris@aurora:~/IdeaProjects/jitwatch/ui/target$ more META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.6.0
Built-By: chris
Build-Jdk: 17
Main-Class: org.adoptopenjdk.jitwatch.launch.LaunchUI
Add-Exports-Private: jdk.jdeps/com.sun.tools.javap

which looks OK but when I run the jar:

chris@aurora:~/IdeaProjects/jitwatch$ /home/chris/jdk-17/bin/java -jar ui/target/ui-shaded.jar 

and then run JITWatch I still get the fallback to ProcessBuilder:

21:30:11.582 [Thread-3] INFO  o.a.j.l.BytecodeLoader - Could not fetch bytecode via reflection, trying Process
21:30:11.583 [Thread-3] INFO  o.a.j.p.r.RuntimeJava - JavapProcess() executablePath: /home/chris/jdk-17/bin/javap

Any ideas?

from jitwatch.

Thihup avatar Thihup commented on June 3, 2024

From the JEP [1], the manifest attribute is Add-Exports instead of Add-Exports-Private. Could you give it a try?

[1] https://openjdk.java.net/jeps/261#Packaging:-Modular-JAR-files

from jitwatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.