jpype-project / jpype

JPype is cross language bridge to allow Python programs full access to Java class libraries.
http://www.jpype.org
Apache License 2.0
1.12k stars 182 forks source link

Load class error #1127

Open for-just-we opened 1 year ago

for-just-we commented 1 year ago

I try to load class from cpg, when I load its dependencies. For example

jpype.addClassPath("libs/slf4j-api-2.0.5-sources.jar")
jpype.addClassPath("libs/slf4j-api-2.0.5.jar")

jpype.addClassPath("libs/log4j-api-2.19.0.jar")
jpype.addClassPath("libs/log4j-core-2.19.0.jar")
jpype.addClassPath("libs/log4j-slf4j2-impl-2.19.0.jar")

jpype.addClassPath("libs/org.eclipse.equinox.common-3.17.0.jar")
jpype.addClassPath("libs/org.eclipse.core.runtime-3.26.0.jar")
jpype.addClassPath("libs/core-8.0.0.202211292120.jar")

LoggerFactory = jpype.JClass("org.slf4j.LoggerFactory")
String = jpype.JClass('java.lang.String')
# 调用 Java 方法
result = String('Hello, JPype!').toLowerCase()
# 打印结果
print(result)

GCCLanguage = jpype.JClass("org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage")
dialect = GCCLanguage.getDefault()

Everything works fine. However, when I load a class from cpg,

jpype.addClassPath("libs/cpg-core-6.1.0.jar")
TranslationConfiguration = jpype.JClass("de.fraunhofer.aisec.cpg.TranslationConfiguration")

Error occured, the message is:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) at pc=0x00007ffbb587cb69, pid=13456, tid=13752
#
# JRE version: OpenJDK Runtime Environment (17.0.2+8) (build 17.0.2+8-86)
# Java VM: OpenJDK 64-Bit Server VM (17.0.2+8-86, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# C  [KERNELBASE.dll+0x2cb69]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  S U M M A R Y ------------

Command Line: 

Host: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, 12 cores, 15G,  Windows 10 , 64 bit Build 19041 (10.0.19041.2788)
Time: Sat Apr 22 20:18:10 2023 �й���׼ʱ�� elapsed time: 0.934590 seconds (0d 0h 0m 0s)

How could I fix this? Are this correlated to the fact that lib cpg is built in java 17 and written in kotlin?

Thrameos commented 1 year ago

Seems like the library has a native component and it didnt match the system. But that is only a guess.

mei71 commented 1 year ago

Have you solved your problem? I have the same problem.

for-just-we commented 1 year ago

Have you solved your problem? I have the same problem.

No, I still haven't found out.

marscher commented 2 weeks ago

Does the code work, if you only use it in the JVM/plain Java?