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

Javascript 无法引用非java core class #296

Open
jianwu opened this issue Oct 31, 2020 · 1 comment · May be fixed by #297
Open

Javascript 无法引用非java core class #296

jianwu opened this issue Oct 31, 2020 · 1 comment · May be fixed by #297

Comments

@jianwu
Copy link

jianwu commented Oct 31, 2020

非常喜欢js的功能。不过有一个问题,就是在javascript里,只能访问core javaclass,比如:
var pi = Packages.java.lang.Math.PI

不过非java core class就访问不到了,
比如:
var pi = Packages.org.apache.commons.lang3.math. NumberUtils .BYTE_MINUS_ONE

我已经确认classload可以load这个class。从源码里,看不到block这些class,不知是什么原因?

不知是不是我的server的secruity manager的问题?

@jianwu
Copy link
Author

jianwu commented Nov 1, 2020

做了一些研究,发现是classloader的问题,javascript engine 缺省使用:thread context classloader。不可以访问applicaton class loader。参考:https://stackoverflow.com/questions/30225398/java-8-scriptengine-across-classloaders/30251930#30251930

我在我本地fix了这个问题,加一个class loader的选项。发一个PR

@jianwu jianwu linked a pull request Nov 1, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant