Emitting JVM Bytecode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Emitting JVM Bytecode

Stefan Krecher-3
Hi,
in the blog:
http://www.redline.st/blog/2012/05/01/emitting-jvm-bytecodes.html 
is described how to emit bytecode - i guess one could use it to just instantiate/ call Java classes/ objects.
Transcript.st uses this mechanism to access a PrintStream.
A little more generic way to call Java would be really great.
Could anybody write some simple examples on how to create and call Java objects?
thanks,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Emitting JVM Bytecode

James Ladd
There is quite a bit involved in documenting how the bytecodes come into play.
There is no quick way - TL;DR; way to get started.

I'm in the process of writing an automatic adaptor to Java classes so you can simply import
the Java class and it appears to you as a Smalltalk class that understands all the underlying
Java Methods. This is still a work in progress, so for now ....

To get started I suggest you read the JVM Bytecode specification so you can understand the bytecodes and
how the JVM works internally, then look through the examples in the Redline Runtime Source to and move forward
with that. Grep for JVM in the .st files and you will see l lots of examples.

I wish I could give you and easier way forward right now, but it is a little way off (months).

- James.

On Tuesday, 21 August 2012 01:33:06 UTC+10, Stefan Krecher wrote:
Hi,
in the blog:
http://www.redline.st/blog/2012/05/01/emitting-jvm-bytecodes.html 
is described how to emit bytecode - i guess one could use it to just instantiate/ call Java classes/ objects.
Transcript.st uses this mechanism to access a PrintStream.
A little more generic way to call Java would be really great.
Could anybody write some simple examples on how to create and call Java objects?
thanks,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Emitting JVM Bytecode

James Ladd
oops forgot to ask an important question - what is the particular situation where you want to call
Java objects from Smalltalk?

On Tuesday, 21 August 2012 09:34:21 UTC+10, jamesl wrote:
There is quite a bit involved in documenting how the bytecodes come into play.
There is no quick way - TL;DR; way to get started.

I'm in the process of writing an automatic adaptor to Java classes so you can simply import
the Java class and it appears to you as a Smalltalk class that understands all the underlying
Java Methods. This is still a work in progress, so for now ....

To get started I suggest you read the JVM Bytecode specification so you can understand the bytecodes and
how the JVM works internally, then look through the examples in the Redline Runtime Source to and move forward
with that. Grep for JVM in the .st files and you will see l lots of examples.

I wish I could give you and easier way forward right now, but it is a little way off (months).

- James.

On Tuesday, 21 August 2012 01:33:06 UTC+10, Stefan Krecher wrote:
Hi,
in the blog:
http://www.redline.st/blog/2012/05/01/emitting-jvm-bytecodes.html 
is described how to emit bytecode - i guess one could use it to just instantiate/ call Java classes/ objects.
Transcript.st uses this mechanism to access a PrintStream.
A little more generic way to call Java would be really great.
Could anybody write some simple examples on how to create and call Java objects?
thanks,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Emitting JVM Bytecode

Stefan Krecher-3
Hi,
i was just playing around with redline, because i want to go on with the eclipse-plugin. I wanted to do some examples that go beyond Hello World. Maybe accessing some Java-Frameworks. I thought of a little workspace-view as a swing-application, and then maybe an implementation of ProfStef. But i noticed, that the class-library is far away from being usable.
I asked myself it was making sense to enhace the class-lib by using "JVM" calls. For example the Date class does nothing. How would an implementation look like? would "Date today" call a primitive? Or wouldn't it be better if "Data today" get the date via the JVM-mechanism?
regards,
Stefan

Am Dienstag, 21. August 2012 07:19:06 UTC+2 schrieb jamesl:
oops forgot to ask an important question - what is the particular situation where you want to call
Java objects from Smalltalk?

On Tuesday, 21 August 2012 09:34:21 UTC+10, jamesl wrote:
There is quite a bit involved in documenting how the bytecodes come into play.
There is no quick way - TL;DR; way to get started.

I'm in the process of writing an automatic adaptor to Java classes so you can simply import
the Java class and it appears to you as a Smalltalk class that understands all the underlying
Java Methods. This is still a work in progress, so for now ....

To get started I suggest you read the JVM Bytecode specification so you can understand the bytecodes and
how the JVM works internally, then look through the examples in the Redline Runtime Source to and move forward
with that. Grep for JVM in the .st files and you will see l lots of examples.

I wish I could give you and easier way forward right now, but it is a little way off (months).

- James.

On Tuesday, 21 August 2012 01:33:06 UTC+10, Stefan Krecher wrote:
Hi,
in the blog:
http://www.redline.st/blog/2012/05/01/emitting-jvm-bytecodes.html 
is described how to emit bytecode - i guess one could use it to just instantiate/ call Java classes/ objects.
Transcript.st uses this mechanism to access a PrintStream.
A little more generic way to call Java would be really great.
Could anybody write some simple examples on how to create and call Java objects?
thanks,
Stefan