GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
318 stars 59 forks source link

App Engine local emulation fails with JDK8 "Unrecognized option: --add-opens" #3136

Closed etanshaul closed 1 year ago

etanshaul commented 1 year ago

Since release 23.4.1, running a local App Engine local emulator with a JDK8, leads to the following error:

Starting the App Engine local development server...
Unrecognized option: --add-opens
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Disconnected from server

Current workarounds

etanshaul commented 1 year ago

Some notes from initial investigation.

From the IDE logs, --add-opens is being issued from the appengine-plugins-core library:

com.google.cloud.tools.appengine.operations.DevAppServerRunner - submitting command: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/bin/java --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.https=ALL-UNNAMED -Duse_jetty9_runtime=true -D--enable_all_permissions=true -Dappengine.sdk.root=/Users/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/java -cp /Users/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/java/lib/appengine-tools-api.jar com.google.appengine.tools.development.DevAppServerMain --address=localhost --port=8080 --allow_remote_shutdown --disable_update_check --no_java_agent /Users/...

A relevent PR that added this into the library from a while ago: https://github.com/GoogleCloudPlatform/appengine-plugins-core/pull/894/files

Still not clear what changed, or why java 8 isn't being recognized properly to omit these flags.

etanshaul commented 1 year ago

On closer look, the referenced PR above is introducing the --add-open flags via:

if (!JAVA_SPECIFICATION_VERSION.value().equals("1.8")) {
      // Due to JPMS restrictions, Java11 or later need more flags:
      jvmArguments.add("--add-opens");
      jvmArguments.add("java.base/java.net=ALL-UNNAMED");
      jvmArguments.add("--add-opens");
      jvmArguments.add("java.base/sun.net.www.protocol.http=ALL-UNNAMED");
      jvmArguments.add("--add-opens");
      jvmArguments.add("java.base/sun.net.www.protocol.https=ALL-UNNAMED");
    }

Cloud Code picked up these changes with its last release. Apparently that code is not guarding properly and still adding the flags when using JDK8.

ivanporty commented 1 year ago

This was fixed in patch release 23.5.1. Please reopen if you encounter this issue again.