Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Freshmark doesn't work on JDK 15 due to missing Nashorn #803

Closed
LunNova opened this issue Feb 16, 2021 · 2 comments
Closed

Freshmark doesn't work on JDK 15 due to missing Nashorn #803

LunNova opened this issue Feb 16, 2021 · 2 comments
Labels

Comments

@LunNova
Copy link

LunNova commented Feb 16, 2021

Nashorn was removed in JDK 15, and freshmark depends on it so crashes.

Caused by: java.lang.RuntimeException: Error on line 21: Cannot invoke "javax.script.ScriptEngine.getContext()" because "jsEngine" is null
        at com.diffplug.freshmark.Parser$1ErrorFormatter.lambda$wrap$2(Parser.java:89)
        at com.diffplug.freshmark.ParserIntronExon.bodyAndTags(ParserIntronExon.java:71)
        at com.diffplug.freshmark.Parser.compile(Parser.java:162)
        at com.diffplug.freshmark.CommentScript.compile(CommentScript.java:85)
        ... 141 more
Caused by: java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.getContext()" because "jsEngine" is null
        at com.diffplug.jscriptbox.javascript.Nashorn.lambda$language$0(Nashorn.java:43)
        at com.diffplug.jscriptbox.JScriptBox.build(JScriptBox.java:89)
        at com.diffplug.freshmark.FreshMark.setupScriptEngine(FreshMark.java:65)
        at com.diffplug.freshmark.CommentScript.lambda$compileSection$0(CommentScript.java:71)
        at com.diffplug.common.base.Errors$Rethrowing.lambda$wrap$11(Errors.java:342)
        at com.diffplug.common.base.Errors$Rethrowing.get(Errors.java:334)
        at com.diffplug.freshmark.CommentScript.compileSection(CommentScript.java:70)
        at com.diffplug.freshmark.Parser$1State.tag(Parser.java:144)
        at com.diffplug.freshmark.Parser$1ErrorFormatter.lambda$wrap$2(Parser.java:78)
        ... 144 more

Gradle version: 6.8.2
JDK version: AdoptOpenJDK jdk-15.0.1.9-hotspot
OS version: Windows 10 20H2
Freshmark config:

spotless.freshmark(it -> {
	it.properties(props -> props.putAll(settings.toProperties(project)));
	it.target(files(project, "**/*.md"));
	it.indentWithTabs();
	it.endWithNewline();
});

This can be worked around by adding nashorn-core to the buildscript classpath:

buildscript {
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.openjdk.nashorn:nashorn-core:15.2")
	}
}
@nedtwigg nedtwigg added the bug label Feb 17, 2021
@nedtwigg
Copy link
Member

Thanks! We should build this into Spotless transparently. We can do it like this:

  • Move JreVersion from testlib into lib, keep the assume() methods in testlib in a new class JreVersionAssume
  • Refactor GoogleJavaFormatStep to use that too
  • Depending on JreVersion, add the nashorn-core dep into the JarState below

() -> new State(JarState.from(MAVEN_COORDINATE + version, provisioner), properties.get()),

I'm still on Java 8 personally, so this isn't going to make the top of my TODO anytime soon. Happy to take a PR! We're already doing CI on JRE 15, so the testing part should be pretty straightforward.

@nedtwigg
Copy link
Member

nedtwigg commented Feb 5, 2023

Fixed in plugin-gradle 6.14.1 thanks to @beegee1.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants