Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » IllegalAccessException for java.lang.Math.random(Public method incorrectly reported as private in EVL)
IllegalAccessException for java.lang.Math.random [message #1760381] Wed, 26 April 2017 14:21 Go to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 65
Registered: November 2015
Location: York, UK
Member
Hello,

I am experimenting with some code in EVL and have the following constraint (context omitted for brevity):

constraint busyComp {
	check {
		var Math : new Native("java.lang.Math");
		var rand : Real = 0.1;
		while (rand < 0.95) {
			rand = Math.random();
		}
		return true;
	}
}


However, I get the following error when I run this:

Internal error: java.lang.IllegalAccessException: Class org.eclipse.epsilon.eol.types.EolClasspathNativeTypeDelegate can not access a member of class java.lang.Math with modifiers "private"

I'm not sure if this is a bug or I'm using the wrong syntax to declare a native type? For reference, java.lang.Math.random() is a static method which returns a double.
Thanks.
Re: IllegalAccessException for java.lang.Math.random [message #1760383 is a reply to message #1760381] Wed, 26 April 2017 14:32 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 65
Registered: November 2015
Location: York, UK
Member
OK I think I've fixed it. The correct syntax is:

var Math = Native("java.lang.Math");
Re: IllegalAccessException for java.lang.Math.random [message #1760433 is a reply to message #1760383] Thu, 27 April 2017 07:14 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1562
Registered: July 2009
Location: York, UK
Senior Member

That's right. Since random() is a static method it needs to be called straight on the Math class.

Cheers,
Dimitris
Re: IllegalAccessException for java.lang.Math.random [message #1760515 is a reply to message #1760433] Thu, 27 April 2017 22:17 Go to previous message
Sina Madani is currently offline Sina MadaniFriend
Messages: 65
Registered: November 2015
Location: York, UK
Member
Ah ok thanks for the explanation.
Previous Topic:Problem running ETL transformation
Next Topic:Some rules work other don't
Goto Forum:
  


Current Time: Mon Jul 16 02:37:12 GMT 2018

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

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

Back to the top