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

[ISSUE #550] Update java option setting to run in jdk9 #1035

Closed
wants to merge 3 commits into from

Conversation

husterxsp
Copy link
Contributor

What is the purpose of the change

Fix issue #550#436.

These are some reasons for the commit.

  1. JDK1.8 don't support PermSize and replace it with Metaspace.
  2. JDK9 don't support -Djava.ext.dirs, and use -classpath instead.
  3. JDK9 don't support PrintGCDetails, and replace it with -Xlog:gc and -Xlog:gc*
  4. JDK9 don’t support UseCMSCompactAtFullCollection.
  5. UseParNewGC was deprecated in Java 9 and removed in Java 10.
  6. UseConcMarkSweepGC was deprecated in Java 9.
  7. JDK9 Make G1 the default garbage collector
  8. About --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED
    In JDK9,after starting the broker, and then type ^C to shutdown it. I got exception as follow:
^CException in thread "ShutdownHook" java.lang.IllegalStateException: java.lang.reflect.InaccessibleObjectException: Unable to make public void jdk.internal.ref.Cleaner.clean() accessible: module java.base does not "exports jdk.internal.ref" to unnamed module @55634720
    at org.apache.rocketmq.store.MappedFile$1.run(MappedFile.java:105)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.apache.rocketmq.store.MappedFile.invoke(MappedFile.java:98)
    at org.apache.rocketmq.store.MappedFile.clean(MappedFile.java:94)
    at org.apache.rocketmq.store.StoreCheckpoint.shutdown(StoreCheckpoint.java:69)
    at org.apache.rocketmq.store.DefaultMessageStore.shutdown(DefaultMessageStore.java:268)
    at org.apache.rocketmq.broker.BrokerController.shutdown(BrokerController.java:748)
    at org.apache.rocketmq.broker.BrokerStartup$1.run(BrokerStartup.java:235)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public void jdk.internal.ref.Cleaner.clean() accessible: module java.base does not "exports jdk.internal.ref" to unnamed module @55634720
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
    at org.apache.rocketmq.store.MappedFile$1.run(MappedFile.java:102)
    ... 8 more

And when I restart by run ./bin/mqbroker, the broker just don’t start, so add --add-exports option to fix it.

In addition, there are still some other problem.
/dev/shm only exists in linux, and does not exist with mac and windows. And run on my mac will get warning: Cannot open file /dev/shm/mq_gc_pid9236.log due to No such file or directory.

Finally, I’ve test the commit in JDK 1.7.0_80、1.8.0_121、9.0.4、10.0.2、11.0.2 on my mac. if it’s all right, the cmd file is also need to be updated.

Brief changelog

Update java option setting to run in jdk9.

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily. Notice, it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@zongtanghu
Copy link
Contributor

@husterxsp Hi,can you resolve the failed error check in your local enviroment.

@zongtanghu zongtanghu added this to the 4.6.0 milestone Mar 11, 2019
@zongtanghu zongtanghu self-requested a review March 11, 2019 06:54
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 49.389% when pulling 6e7a450 on husterxsp:develop into 5134a8e on apache:develop.

@husterxsp
Copy link
Contributor Author

@husterxsp Hi,can you resolve the failed error check in your local enviroment.

@zongtanghu Hi, I have just merged develop branch and all checks have passed currently. I'm not sure if it's ok now.

Copy link
Contributor

@liuruiyiyang liuruiyiyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I think we need to consider how to transfer old parameters in JDK8 to JDK9 and above, e.g. the GC log related parameters.

if [[ "$JAVA_MAJOR_VERSION" -lt 9 ]] ; then
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for curiosity, do we need to add ${BASE_DIR}/lib to Djava.ext.dirs if already added ${BASE_DIR}/lib to CLASSPATH when using JDK8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, and i've updated the commit.

JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
else
JAVA_OPT="${JAVA_OPT} --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to add some corresponding parameters of GC log for JDK9 and above here?
e.g. -Xlog:gc*:file=/dev/shm/mq_gc_%p.log:timemillis:filecount=5,filesize=30720

And other params like PrintGCApplicationStoppedTime and PrintAdaptiveSizePolicy are also needed to be transferred in JDK9.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I‘m not very familiar with the parameters. According to https://docs.oracle.com/javase/9/tools/java.htm#JSWOR-GUID-BE93ABDC-999C-4CB5-A88B-1994AAAC74D5,maybe we can use -Xlog:safepoint and -Xlog:ergo*=level?

@tendant
Copy link

tendant commented Feb 21, 2020

When can we expect this to be merged?

This stops people from using JDK 9+.

@zongtanghu
Copy link
Contributor

There is some code conflicts, in this pr, please resolve the conflicts firstyl. @husterxsp

@vongosling vongosling closed this May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants