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

Closure minification fails under Nashorn #822

Closed
mamacdon opened this issue Jun 24, 2015 · 1 comment
Closed

Closure minification fails under Nashorn #822

mamacdon opened this issue Jun 24, 2015 · 1 comment

Comments

@mamacdon
Copy link
Contributor

Running 2.1.18 under Java 8+Nashorn with optimize=closure, minification fails with an error:

TypeError: Cannot read property "invoke" from undefined

It is caused by this code in jslib/rhino/optimize.js:

//Bind to Closure compiler, but if it is not available, do not sweat it.
try {
    // Try older closure compiler that worked on Java 6
    JSSourceFilefromCode = java.lang.Class.forName('com.google.javascript.jscomp.JSSourceFile').getMethod('fromCode', [java.lang.String, java.lang.String]);
} catch (e) {
    try {
        // Try for newer closure compiler that needs Java 7+
        JSSourceFilefromCode = java.lang.Class.forName('com.google.javascript.jscomp.SourceFile').getMethod('fromCode', [java.lang.String, java.lang.String]);
    } catch (e) {}
}

//Helper for closure compiler, because of weird Java-JavaScript interactions.
function closurefromCode(filename, content) {
    return JSSourceFilefromCode.invoke(null, [filename, content]); // <-- error happens here**
}

Under Nashorn, the calls to java.lang.Class.forName(...) throw, which cause an error on the indicated line.

@mamacdon
Copy link
Contributor Author

Created pull request #823, which fixes the issue for me.

jrburke added a commit that referenced this issue Jul 11, 2015
Try `Java.type().class` for Nashorn (fixes #822)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant