Hi,
this is my scenario: I run an Amber-Program (prepared with a mechanism similar to amberc but coded in Java) on Rhino (stared from a Java-Program). This generally works fine. I use the <>-syntax to call Javaclasses from Amber, eg. <importPackage (javax.swing)>. <JOptionPane.showMessageDialog(null, 'Hey ho, lets go');>. this works too. But when i write: JOptionPane showMessageDialog: #(nil 'Hey ho, lets go'). I get the following Exception: org.mozilla.javascript.JavaScriptException: InternalError: Java class "javax.swing.JOptionPane" has no public instance field or method named "klass". (<cmd>#348) (<cmd>#335) I have no Idea what's happening since i thought this is the correct syntax for calling Javascript from Amber. In Rhino it's no difference if i call a Javascript or a Java-Object - unless i import that Javapackage. Hints anyone? regards, Stefan |
did some further investigations but could not solve the problem. Seems like instantiation in Amber always implies the enhancement of objects with methods like "klass" which leads to problems if a Java-class is intantiated. Could there be a way to check if an Object is an Java Object and then behave differently? Without doing a distinction, i need to use <> notation to instantiate a Java-class. Although this is cool, it would be even cooler to write "pane := JOptionPane new" instead of "<pane = new JOptionPane();>." (see the example below) regards, Stefan | pane dialog | <importPackage (javax.swing)>. <pane = new JOptionPane();>. pane setMessage: 'Ha!'. pane setVisible: true. dialog := pane createDialog: 'this is the title'. dialog setVisible: true. ^'Return from Amber'
|
I am amazed that this works.
You could modify the smalltalk.send methods for checking if it has a klass-attribute and if not ivoke direktly, maybe? On Mon, Jan 2, 2012 at 2:36 PM, Stefan Krecher <[hidden email]> wrote:
|
On 01/04/2012 10:21 AM, Amber Milan Eskridge wrote:
> I am amazed that this works. > You could modify the smalltalk.send methods for checking if it has a > klass-attribute and if not ivoke direktly, maybe? We *really* don't want to do more than absolutely needed in those methods - performance... BUT... we could rename "klass" to "klas" :) regards, Göran |
Would that help? As I understand it, it is a problem with the immutability of Java classes / objects that get new attributes attached through the runtime, no?
2012/1/4 Göran Krampe <[hidden email]>
|
On 01/04/2012 10:30 AM, Amber Milan Eskridge wrote:
> Would that help? As I understand it, it is a problem with the > immutability of Java classes / objects that get new attributes attached > through the runtime, no? Ah, right. I thought it was some kind of name clash. You are probably right. regards, Göran |
Am 4. Januar 2012 10:36 schrieb Göran Krampe <[hidden email]>:
>> Would that help? As I understand it, it is a problem with the >> immutability of Java classes / objects that get new attributes attached >> through the runtime, no? > Ah, right. I thought it was some kind of name clash. You are probably right. yes, it's no name clash ... There seem to be even more problems like calling an inherited method of a Java-Class. But other things a really really really cool, e.g.: Instantiating a Swing JButton via: <buttonPrintit = new JButton('print it');>. and attaching an ActionListener via buttonPrintit addActionListener: [ self messageBox: (self eval: (textArea getSelectedText)) ]. It's amazing! addActionListener is a Java-Method that takes an Java-Object that implements the ActionListener-Interface. But i send a BlockClosure - and it works! It must be magic - i'm so excited :-) -- Dipl.-Wirtsch.-Inf. Stefan Krecher Neulander Str. 17, 27374 Visselhövede Tel +49(0)4262 958848 mobil +49(0)172 3608616 http://krecher.com |
Free forum by Nabble | Edit this page |