可以JNI提出,要兑现在classpath中通配符扩展? [英] Can JNI be made to honour wildcard expansion in the classpath?
问题描述
我有一个C二进制文件通过JNI调用了去渣。我设置CLASSPATH以somedir / *拿起所有的罐子在somedir。
I have a C binary that calls out to Java via JNI. I set CLASSPATH to somedir/* to pick up all the jars in somedir.
当我运行的二进制,所需的类定义不能被发现。当我运行
When I run the binary, a required class definition cannot be found. When I run
java that.class's.name
从相同的命令行,类被成功找到。如果我明确地添加所有的罐子在somedir /到classpath中,一切都很正常,但导致的非常的类路径很长,我想这避免。
from the same command line, the class is successfully found. If I explicitly add all the jars in somedir/ to the classpath, everything works great, but that leads to a very long classpath which I'd like to avoid.
通过是否在classpath的JNI荣誉通配符扩展执行的JVM?是否可以做这样的?
Does a JVM executed via JNI honour wildcard expansion of the classpath? Can it be made to do so?
推荐答案
我通过阅读热点源$ C $ C想出答案。
I figured out the answer by reading the hotspot source code.
只能通过两种 CLASSPATH
或 -cp
/ -classpath $传递路径C $ C>受通配符扩展。然后这些作为一个系统属性来运行的JVM通过
-Djava.class.path
过去了。
Only paths passed via either CLASSPATH
or -cp
/ -classpath
are subject to wildcard expansion. These are then passed as a system property to the running JVM via -Djava.class.path
.
您告诉JNI调用的JVM关于通过 JVMOptions
结构的类路径中,其中可能包括 -Djava.class.path
,但 -classpath
不会的不一定的荣幸(并在实践中,是不是热点实现)。由于 java.class.path
直接传递给JVM的系统属性,它不会通配符扩展,因此通配符将不起作用。
You tell a JNI-invoked JVM about a classpath via a JVMOptions
structure, which may include -Djava.class.path
but -classpath
will not necessarily be honoured (and in practice, isn't by the hotspot implementation). Since java.class.path
is directly passed to the JVM as a system property, it doesn't get wildcard expanded and therefore wildcards won't work.
这篇关于可以JNI提出,要兑现在classpath中通配符扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!