Giter VIP home page Giter VIP logo

Comments (6)

bmarcaur avatar bmarcaur commented on June 2, 2024

To also confirm, this worked on jdk 15:

openjdk version "15.0.4" 2021-07-20
OpenJDK Runtime Environment Zulu15.34+17-CA (build 15.0.4+5-MTS)
OpenJDK 64-Bit Server VM Zulu15.34+17-CA (build 15.0.4+5-MTS, mixed mode, sharing)

from palantir-java-format.

carterkozak avatar carterkozak commented on June 2, 2024

This is due to JEP 396: Strongly Encapsulate JDK Internals by Default
We haven't adopted java 16 internally since the supported lifespan is too short for us to roll off in time, however we're beginning to work on Java 17 support.

from palantir-java-format.

iamdanfox avatar iamdanfox commented on June 2, 2024

That JEP dangles some tantalising options:

It will still be possible to use the --add-opens command-line option, or the Add-Opens JAR-file manifest attribute, to open specific packages.

https://openjdk.java.net/jeps/261#Packaging:-Modular-JAR-files - could this be as easy as just embedding a module-info.class file that specifies all the crazy --add-opens things this project needs?

<module name="palantir-java-format" options="--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" />

EDIT seems like I confused --add-exports with --add-opens - maybe this won't be so easy

from palantir-java-format.

fawind avatar fawind commented on June 2, 2024

Some relevant context from how google-java-format is tackling this: issue, readme.

Basically their solution for running with Java16+ is that you have to run the formatter with --add-exports flags added. Bit unfortunate and we might have to do some hacky stuff to get this working as Gradle integration or with the intellij plugin. One option might be to do something like bootstrapping our own jre when trying to format some files so we can pass through our flags (as mentioned here).

from palantir-java-format.

fawind avatar fawind commented on June 2, 2024

The latest version should work with Java 16+. However depending on how you invoke the formatter you need to add --add-exports flags due to JEP 396: Strongly Encapsulate JDK Internals by Default.

When running the formatter through Gradle, you can for example add the args to your gradle.properties file:

org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

The intellij plugin and integration with palantir/goethe will automatically add these flags for you.

Closing this issue for now. Please re-open if you run into further issues!

from palantir-java-format.

raiju avatar raiju commented on June 2, 2024

Note that I couldn't get goethe to add the flags in modern gradle (filed here: palantir/goethe#91)

from palantir-java-format.

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.