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

Doc: We can metion the Java 21's new switch statement. #979

Closed
He-Pin opened this issue Jan 19, 2024 · 7 comments
Closed

Doc: We can metion the Java 21's new switch statement. #979

He-Pin opened this issue Jan 19, 2024 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@He-Pin
Copy link
Member

He-Pin commented Jan 19, 2024

Motivation:
When handle an actor's messages, in Scala ,we can use the pattern matching, but now with JDK 21, we can use the new fancy :

switch(msg) {
  case XEvent event -> handle(event);
  default _ -> unhandled(msg);

style, and which will leverage the typeSwitch and maybe better performance vs the if else.

@He-Pin He-Pin added the help wanted Extra attention is needed label Jan 19, 2024
@He-Pin He-Pin changed the title Doc: We can metion the jJava 21 Doc: We can metion the Java 21's new switch statement. Jan 19, 2024
@duobei
Copy link
Contributor

duobei commented Jan 21, 2024

When I execute sbt docs/paradoxBrowse, it raised a error:

[error] java.lang.RuntimeException: Error creating extended parser class: Could not determine whether class 'org.pegdown.ParserWithDirectives$$parboiled' has already been loaded
[error] 	at org.parboiled.Parboiled.createParser(Parboiled.java:58)
[error] 	at com.lightbend.paradox.markdown.Reader.<init>(Reader.scala:40)
[error] 	at com.lightbend.paradox.sbt.ParadoxPlugin$.$anonfun$baseParadoxSettings$2(ParadoxPlugin.scala:83)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] 	at sbt.Execute.work(Execute.scala:292)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] 	at java.base/java.lang.Thread.run(Thread.java:833)
[error] Caused by: java.lang.RuntimeException: Could not determine whether class 'org.pegdown.ParserWithDirectives$$parboiled' has already been loaded
[error] 	at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:217)
[error] 	at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:35)
[error] 	at org.parboiled.Parboiled.createParser(Parboiled.java:54)
[error] 	at com.lightbend.paradox.markdown.Reader.<init>(Reader.scala:40)
[error] 	at com.lightbend.paradox.sbt.ParadoxPlugin$.$anonfun$baseParadoxSettings$2(ParadoxPlugin.scala:83)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] 	at sbt.Execute.work(Execute.scala:292)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] 	at java.base/java.lang.Thread.run(Thread.java:833)
[error] Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not "opens java.lang" to unnamed module @57103ee8
[error] 	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
[error] 	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
[error] 	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
[error] 	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
[error] 	at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:210)
[error] 	at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:35)
[error] 	at org.parboiled.Parboiled.createParser(Parboiled.java:54)
[error] 	at com.lightbend.paradox.markdown.Reader.<init>(Reader.scala:40)
[error] 	at com.lightbend.paradox.sbt.ParadoxPlugin$.$anonfun$baseParadoxSettings$2(ParadoxPlugin.scala:83)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] 	at sbt.Execute.work(Execute.scala:292)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] 	at java.base/java.lang.Thread.run(Thread.java:833)
[error] (docs / Compile / paradoxProcessor) Error creating extended parser class: Could not determine whether class 'org.pegdown.ParserWithDirectives$$parboiled' has already been loaded

@pjfanning
Copy link
Contributor

sbt paradox commands are best with Java 11.

@duobei
Copy link
Contributor

duobei commented Jan 21, 2024

sbt paradox commands are best with Java 11.

But it can't work with Java 17.

@He-Pin
Copy link
Member Author

He-Pin commented Jan 21, 2024

@duobei Yes, in Java 17 , you need add opens, something like :

             --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.main=ALL-UNNAMED
                            --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
                            --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
                            --add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
                            --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
                            --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
                            --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
                            --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
                            --add-opens java.base/java.lang=ALL-UNNAMED
                            --add-opens java.base/java.net=ALL-UNNAMED
                            --add-opens java.base/java.util=ALL-UNNAMED
                            --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
                            --add-opens java.base/java.nio=ALL-UNNAMED
                            --add-opens java.base/jdk.internal.misc=ALL-UNNAMED
                            --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED
                            --add-exports java.base/sun.util.calendar=ALL-UNNAMED
                            --add-exports java.base/java.lang.reflect=ALL-UNNAMED
                            --add-opens java.base/sun.net.util=ALL-UNNAMED
                            --add-opens java.base/sun.nio.ch=ALL-UNNAMED
                            --add-opens java.base/java.math=ALL-UNNAMED
                            --add-opens java.base/sun.security.action=ALL-UNNAMED
                            --add-opens java.management/sun.management=ALL-UNNAMED

@Roiocam
Copy link
Member

Roiocam commented Jan 26, 2024

@duobei Yes, in Java 17 , you need add opens, something like :

I think we have a plugin PekkoDisciplinePlugin which can be filled in Scala or Java options, Can you try to produce a setting for JDk17? Thanks.

@He-Pin
Copy link
Member Author

He-Pin commented Jan 27, 2024

It's experimental in jdk 17?

@pjfanning
Copy link
Contributor

#1011 was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants