Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » sys_paths error in epsilon simulink api(Cannot use epsilon api to communicate with Simulink)
sys_paths error in epsilon simulink api [message #1860410] Thu, 03 August 2023 14:35 Go to next message
Alexey Shamanaev is currently offline Alexey ShamanaevFriend
Messages: 4
Registered: August 2023
Junior Member
Hello Epsilon developres,

I'm trying to use Epsilon java api to communicate with Simulink.
I added the appropriate dependency to my Maven project:
<dependency>
    		<groupId>org.eclipse.epsilon</groupId>
    		<artifactId>org.eclipse.epsilon.emc.simulink</artifactId>
    		<version>2.4.0</version>
</dependency>


Everything works fine, but there is just one problem - it work only with JDK 1.8 (amazon-corretto).
If I try to use another JDK version (11 for example) I get this error:
Caused by: java.lang.NoSuchFieldException: sys_paths
	at java.base/java.lang.Class.getDeclaredField(Class.java:2707)
	at org.eclipse.epsilon.emc.simulink.engine.MatlabEnginePool.<init>(MatlabEnginePool.java:47)
	... 54 more

The reason of this error is this line of code (inside MatlabEnginePool.java):
final Field sysPathsField = ClassLoader.class.getDeclaredField(SYS_PATHS);

i.e. it tries to find sys_paths field in ClassLoader class, cannot find it and falls with the exception.
I checked class loaders for different version of JDK and discovered that JDK 1.8 contains this field but the higher versions are not.

I also checked the sources of Epsilon platform on Github https://github.com/eclipse/epsilon
and found out that the bag is already fixed there:
                        // Updating the library path in Java 11 onwards on Windows causes an exception. 
			// Only do this for older Java versions or when not on Windows.
			if ((!OperatingSystem.isWindows() || (ClassLoader.getSystemClassLoader() instanceof URLClassLoader))) {
				final String SEP = System.getProperty("path.separator");
				System.setProperty(JAVA_LIBRARY_PATH, libraryPath + SEP + System.getProperty(JAVA_LIBRARY_PATH));
				final Field sysPathsField = ClassLoader.class.getDeclaredField(SYS_PATHS);

				sysPathsField.setAccessible(true);
				sysPathsField.set(null, null);
			}


So the question is what to do with this lib:
<dependency>
    		<groupId>org.eclipse.epsilon</groupId>
    		<artifactId>org.eclipse.epsilon.emc.simulink</artifactId>
    		<version>2.4.0</version>
</dependency>


Are you going to release a new version with the fix? Or do you have a repo where I can download the sources and buid them by myself?
I think it's quite critical bug because it prevents developer from using the lib.

Thank you.

Re: sys_paths error in epsilon simulink api [message #1860414 is a reply to message #1860410] Thu, 03 August 2023 15:46 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Alexey,

The fix will appear in 2.5.0. Until then, you can use the latest interim version as follows:

<repositories>
    <repository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.eclipse.epsilon</groupId>
        <artifactId>org.eclipse.epsilon.emc.simulink</artifactId>
        <version>2.5.0-SNAPSHOT</version>
    </dependency>
</dependencies>


Thanks,
Dimitris

[Updated on: Thu, 03 August 2023 17:46]

Report message to a moderator

Re: sys_paths error in epsilon simulink api [message #1860427 is a reply to message #1860414] Fri, 04 August 2023 08:21 Go to previous message
Alexey Shamanaev is currently offline Alexey ShamanaevFriend
Messages: 4
Registered: August 2023
Junior Member
Hi Dimitris,

Thank you, works fine now!

Thanks,
Alexey
Previous Topic:How to query XMI file when the name of properties has colon
Next Topic:EMC for INI files
Goto Forum:
  


Current Time: Sat Apr 27 11:12:10 GMT 2024

Powered by FUDForum. Page generated in 0.02505 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top