Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EOL - Native calls to static Java members?
EOL - Native calls to static Java members? [message #774668] Wed, 04 January 2012 06:19 Go to next message
EclipseUser Missing name is currently offline EclipseUser Missing name
Messages: 6
Registered: December 2011
Junior Member
Hello,

I know it's possible with EOL to create a Java object with new Native() like:

var test = new Native('java.util.Vector');

but how would I go about initializing a var from a static function? like: (Java code)

Console console = System.console();

...or just using static members in general.

Thanks.
Re: EOL - Native calls to static Java members? [message #774671 is a reply to message #774668] Wed, 04 January 2012 06:26 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 803
Registered: July 2009
Senior Member
Hi,

Try Native("class-name").staticMethod() e.g. Native("java.lang.Math").abs(5).println();

Cheers,
Dimitris
Re: EOL - Native calls to static Java members? [message #774684 is a reply to message #774671] Wed, 04 January 2012 07:03 Go to previous messageGo to next message
EclipseUser Missing name is currently offline EclipseUser Missing name
Messages: 6
Registered: December 2011
Junior Member
Thanks for the reply,

this seems to work in some instances and not in others. Example that works:

var props = Native("java.lang.System").getProperties();
props.println();


This nicely prints out the properties. But when I try:

var console = Native("java.lang.System").console();
console.readLine();


It says "Method 'readLine' not found", meaning the object doesn't get initialized.
Re: EOL - Native calls to static Java members? [message #774692 is a reply to message #774684] Wed, 04 January 2012 07:13 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 803
Registered: July 2009
Senior Member
Hi,

console appears to be null (i.e. System.console() has returned null - which appears to be legitimate behaviour: http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#console()).

If you need to capture user input during the execution of an EOL program, please have a look at p61 of the Epsilon Book.

Cheers,
Dimitris
Re: EOL - Native calls to static Java members? [message #774708 is a reply to message #774692] Wed, 04 January 2012 07:40 Go to previous messageGo to next message
EclipseUser Missing name is currently offline EclipseUser Missing name
Messages: 6
Registered: December 2011
Junior Member
Thanks.
Re: EOL - Native calls to static Java members? [message #774883 is a reply to message #774708] Wed, 04 January 2012 16:01 Go to previous messageGo to next message
EclipseUser Missing name is currently offline EclipseUser Missing name
Messages: 6
Registered: December 2011
Junior Member
I just came across another problem with boolean parameters when intializing an object with new Native(). For example when trying to initialize a Boolean from a EOL boolean we get the following:

var test = new Native("java.lang.Boolean")(true)

Output: 'Native type java.lang.Boolean does not define a suitable constructor for arguments [true]'

For this example this can be circumvented by using a string parameter to construct the boolean (new Native("java.lang.Boolean")("true")), but there are instances in which we need to pass a primitive type boolean, such as here (to start a modal dialog):

var frame = new Native("javax.swing.JDialog")(new Native("java.awt.Frame"),true);

Output: 'Native type javax.swing.JDialog does not define a suitable constructor for arguments [java.awt.Frame[frame13,0,22,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=,resizable,normal], true]'

The EOL boolean can apparently not be used to initialize a Java object that expects a Java primitive boolean type. Is this a bug? Is there a way I can circumvent this?

Thanks

[Updated on: Wed, 04 January 2012 21:34]

Report message to a moderator

Re: EOL - Native calls to static Java members? [message #775091 is a reply to message #774883] Thu, 05 January 2012 05:01 Go to previous message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 803
Registered: July 2009
Senior Member
Hi,

Thanks for reporting this. This appears to be a bug in the way EOL uses reflection to discover constructors (given that Boolean <> bool it should try with both). Could you please file a bug report using the link below and we'll try to get this fixed asap.

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GMT&component=Epsilon

Cheers,
Dimitris
Previous Topic:Validation with EVL & RCP
Next Topic:Bug in org.eclipse.epsilon.emc.emf
Goto Forum:
  


Current Time: Thu Jul 31 15:49:12 EDT 2014

Powered by FUDForum. Page generated in 0.02074 seconds