NetRexxC working on Android very close!

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

NetRexxC working on Android very close!

Jason Martin
With few changes to original NetRexx a solution that will probably work.

It will require sdcard (can be done the android app way but that is not what I am looking for)

Google provides the android.jar (this is their classes.zip and Java) to develop on the PC.

When I set classpath and java home and lib dir with a copy of that android.jar and NetRexxR.jar in lib on SDCARD

Everybody seems to be happy.

I am down to this error now. (Help or Advice from those who know the Internals)


10-30 08:54:22.554: I/System.out(2300):    +++ Error: Sorry, to interpret classes without compilation you must be running Java 1.2 or later

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Kermit Kiser
Interesting approach.

Re error -  NetRexx is checking the Java version to see if it can perform interpretation. It needs to have Java 1.2 or later. The check is at about line 469 in RxTranslator. Android not being Java is returning version "0" for the call: System.getProperty('java.version')
Try substituting "1.2" if the return value is 0.

-- Kermit

On 10/29/2012 11:07 PM, Jason Martin wrote:
With few changes to original NetRexx a solution that will probably work.

It will require sdcard (can be done the android app way but that is not what I am looking for)

Google provides the android.jar (this is their classes.zip and Java) to develop on the PC.

When I set classpath and java home and lib dir with a copy of that android.jar and NetRexxR.jar in lib on SDCARD

Everybody seems to be happy.

I am down to this error now. (Help or Advice from those who know the Internals)


10-30 08:54:22.554: I/System.out(2300):    +++ Error: Sorry, to interpret classes without compilation you must be running Java 1.2 or later


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Jason Martin
In reply to this post by Jason Martin
Ok, thanks Kermit that takes me a little farther and it crashes. I will work on it more a little later.

10-30 10:12:32.358: I/System.out(526): # FF: 1100 looking for 'Object' in 'java.lang.Object'... 1
10-30 10:12:32.368: I/System.out(526): # method: Object() returns java.lang.Object found in java.lang.Object [0]
10-30 10:12:32.368: I/System.out(526): # closefiles
10-30 10:12:32.388: I/System.out(526): # ===== define proxies =====
10-30 10:12:32.388: I/System.out(526): # loadClass: myprogram [Info]
10-30 10:12:32.418: I/System.out(526): # Building Proxy for: myprogram
10-30 10:12:32.438: I/System.out(526): # --- constant pool: 463 class: 604 ---
10-30 10:12:32.458: I/System.out(526): #     props: 1 meths: 2
10-30 10:12:32.458: I/System.out(526): #     atts: 0 85 8
10-30 10:12:32.468: E/dalvikvm(526): ERROR: defineClass(0x528b0258, myprogram, 0x528e0540, 0, 604, 0x0)
10-30 10:12:32.478: D/AndroidRuntime(526): Shutting down VM
10-30 10:12:32.488: W/dalvikvm(526): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-30 10:12:32.518: E/AndroidRuntime(526): FATAL EXCEPTION: main
10-30 10:12:32.518: E/AndroidRuntime(526): java.lang.UnsupportedOperationException: can't load this type of class file
10-30 10:12:32.518: E/AndroidRuntime(526):     at java.lang.VMClassLoader.defineClass(Native Method)
10-30 10:12:32.518: E/AndroidRuntime(526):     at java.lang.ClassLoader.defineClass(ClassLoader.java:338)
10-30 10:12:32.518: E/AndroidRuntime(526):     at java.lang.ClassLoader.defineClass(ClassLoader.java:301)


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Jason Martin
As a side note, I guessing this is where the dex stuff comes in.

I have loaded dx.jar into my project and I guess I will have to use those the api's from NetRexx.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

billfen
In reply to this post by Jason Martin
Java 1.2 was released in December 1998.

Does it really make sense to be checking for Java 1.2?

Isn't the whole world is at 1.5 or 1.6, waiting for 1.7?

Original Message:
-----------------
From: Kermit Kiser [hidden email]
Date: Mon, 29 Oct 2012 23:35:32 -1000
To: [hidden email]
Subject: Re: [Ibm-netrexx] NetRexxC working on Android very close!


Interesting approach.

Re error -  NetRexx is checking the Java version to see if it can
perform interpretation. It needs to have Java 1.2 or later. The check is
at about line 469 in RxTranslator. Android not being Java is returning
version "0" for the call: System.getProperty('java.version')
Try substituting "1.2" if the return value is 0.

-- Kermit

--------------------------------------------------------------------
mail2web.com – What can On Demand Business Solutions do for you?
http://link.mail2web.com/Business/SharePoint


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

rvjansen
In the context of NetRexx it makes sense because functionality is
handled differently; in currently reality we can remove all these checks
because since 3.01 has been released, the requirement is Java 1.5 - but
still the check is valid for Java. Now with Android in the equation,
dalvik is enough Java to run the test and not enough to not cause
trouble. If you suggest to take out these tests, I would agree.

We have to make sure it is not in the runtime. I am not sure, at the
moment, whether the runtime is not still running at Java 1.1 level, or
not (which might be interesting to the limited devices people). I see
that www.oldversion.com has Java versions for Windows until 1.1.7;
someone with more time than me might do NetRexx a service to set one up
and run tests occasionally to see what still works and what not.

best regards,

René.





On 2012-10-30 15:44, [hidden email] wrote:

> Java 1.2 was released in December 1998.
>
> Does it really make sense to be checking for Java 1.2?
>
> Isn't the whole world is at 1.5 or 1.6, waiting for 1.7?
>
> Original Message:
> -----------------
> From: Kermit Kiser [hidden email]
> Date: Mon, 29 Oct 2012 23:35:32 -1000
> To: [hidden email]
> Subject: Re: [Ibm-netrexx] NetRexxC working on Android very close!
>
>
> Interesting approach.
>
> Re error -  NetRexx is checking the Java version to see if it can
> perform interpretation. It needs to have Java 1.2 or later. The check
> is
> at about line 469 in RxTranslator. Android not being Java is
> returning
> version "0" for the call: System.getProperty('java.version')
> Try substituting "1.2" if the return value is 0.
>
> -- Kermit
>
> --------------------------------------------------------------------
> mail2web.com – What can On Demand Business Solutions do for you?
> http://link.mail2web.com/Business/SharePoint
>
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

rvjansen
A better place would be
http://www.oracle.com/technetwork/java/archive-139210.html where even
1.1.a is available. That might be an interesting project for the NetRexx
historians among us.

best regards,

René.

On 2012-10-30 16:03, rvjansen wrote:

> In the context of NetRexx it makes sense because functionality is
> handled differently; in currently reality we can remove all these
> checks because since 3.01 has been released, the requirement is Java
> 1.5 - but still the check is valid for Java. Now with Android in the
> equation, dalvik is enough Java to run the test and not enough to not
> cause trouble. If you suggest to take out these tests, I would agree.
>
> We have to make sure it is not in the runtime. I am not sure, at the
> moment, whether the runtime is not still running at Java 1.1 level,
> or
> not (which might be interesting to the limited devices people). I see
> that www.oldversion.com has Java versions for Windows until 1.1.7;
> someone with more time than me might do NetRexx a service to set one
> up and run tests occasionally to see what still works and what not.
>
> best regards,
>
> René.
>
>
>
>
>
> On 2012-10-30 15:44, [hidden email] wrote:
>> Java 1.2 was released in December 1998.
>>
>> Does it really make sense to be checking for Java 1.2?
>>
>> Isn't the whole world is at 1.5 or 1.6, waiting for 1.7?
>>
>> Original Message:
>> -----------------
>> From: Kermit Kiser [hidden email]
>> Date: Mon, 29 Oct 2012 23:35:32 -1000
>> To: [hidden email]
>> Subject: Re: [Ibm-netrexx] NetRexxC working on Android very close!
>>
>>
>> Interesting approach.
>>
>> Re error -  NetRexx is checking the Java version to see if it can
>> perform interpretation. It needs to have Java 1.2 or later. The
>> check is
>> at about line 469 in RxTranslator. Android not being Java is
>> returning
>> version "0" for the call: System.getProperty('java.version')
>> Try substituting "1.2" if the return value is 0.
>>
>> -- Kermit
>>
>> --------------------------------------------------------------------
>> mail2web.com – What can On Demand Business Solutions do for you?
>> http://link.mail2web.com/Business/SharePoint
>>
>>
>> _______________________________________________
>> Ibm-netrexx mailing list
>> [hidden email]
>> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Kermit Kiser
In reply to this post by Jason Martin
I wouldn't be too optimistic about that - NetRexx generates Java byte code and loads it in order to interpret programs. Unfortunately, Android byte code is different than Java byte code so I don't see any way around writing some tricky NetRexx code to generate Android byte code or to translate the Java byte code on the fly.

Funny that it did not occur to me back when we debated the idea of NetRexxC directly generating Java byte code that the interpreter was already generating Java byte code for it's own purpose! I wonder if the change in Java 1.2 that allowed Mike to implement the interpreter was related to that dynamic code generation?

-- Kermit


On 10/30/2012 12:20 AM, Jason Martin wrote:
Ok, thanks Kermit that takes me a little farther and it crashes. I will work on it more a little later.

10-30 10:12:32.358: I/System.out(526): # FF: 1100 looking for 'Object' in 'java.lang.Object'... 1
10-30 10:12:32.368: I/System.out(526): # method: Object() returns java.lang.Object found in java.lang.Object [0]
10-30 10:12:32.368: I/System.out(526): # closefiles
10-30 10:12:32.388: I/System.out(526): # ===== define proxies =====
10-30 10:12:32.388: I/System.out(526): # loadClass: myprogram [Info]
10-30 10:12:32.418: I/System.out(526): # Building Proxy for: myprogram
10-30 10:12:32.438: I/System.out(526): # --- constant pool: 463 class: 604 ---
10-30 10:12:32.458: I/System.out(526): #     props: 1 meths: 2
10-30 10:12:32.458: I/System.out(526): #     atts: 0 85 8
10-30 10:12:32.468: E/dalvikvm(526): ERROR: defineClass(0x528b0258, myprogram, 0x528e0540, 0, 604, 0x0)
10-30 10:12:32.478: D/AndroidRuntime(526): Shutting down VM
10-30 10:12:32.488: W/dalvikvm(526): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-30 10:12:32.518: E/AndroidRuntime(526): FATAL EXCEPTION: main
10-30 10:12:32.518: E/AndroidRuntime(526): java.lang.UnsupportedOperationException: can't load this type of class file
10-30 10:12:32.518: E/AndroidRuntime(526):     at java.lang.VMClassLoader.defineClass(Native Method)
10-30 10:12:32.518: E/AndroidRuntime(526):     at java.lang.ClassLoader.defineClass(ClassLoader.java:338)
10-30 10:12:32.518: E/AndroidRuntime(526):     at java.lang.ClassLoader.defineClass(ClassLoader.java:301)



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Jason Martin
In reply to this post by Jason Martin
I would like to interpet but it not - this is using ecj on the device which we have hooks into already.

https://sites.google.com/site/androcoding/classroom-news/howtocompilejavainandroid

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Mike Cowlishaw
In reply to this post by Kermit Kiser
> I wouldn't be too optimistic about that - NetRexx generates Java byte
> code and loads it in order to interpret programs.

That's news to me ... :-)

Mike
         
         


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Robert L Hamilton
Well, Mike, how does NetRexx process programs?

Thanks,

Bob Hamilton
Richardson Texas USA

On Wed, Oct 31, 2012 at 2:49 AM, Mike Cowlishaw <[hidden email]> wrote:

>> I wouldn't be too optimistic about that - NetRexx generates Java byte
>> code and loads it in order to interpret programs.
>
> That's news to me ... :-)
>
> Mike
>
>
>
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

christel.u.w.pachl christel.u.w.pachl
In reply to this post by Jason Martin
It translates to Java which is then compiled....
That much I think (even) I know :-)
Walter
---- Robert Hamilton <[hidden email]> schrieb:

> Well, Mike, how does NetRexx process programs?
>
> Thanks,
>
> Bob Hamilton
> Richardson Texas USA
>
> On Wed, Oct 31, 2012 at 2:49 AM, Mike Cowlishaw <[hidden email]> wrote:
> >> I wouldn't be too optimistic about that - NetRexx generates Java byte
> >> code and loads it in order to interpret programs.
> >
> > That's news to me ... :-)
> >
> > Mike
> >
> >
> >
> >
> > _______________________________________________
> > Ibm-netrexx mailing list
> > [hidden email]
> > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
> >
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Kermit Kiser
In reply to this post by Mike Cowlishaw
Heh... I guess that statement wasn't as clear as it could have been. I
was referring to the RxProxy classes, of course, not the final program
classes.

But I do suspect this is your comment in the source code (;-) :

/*   This is very close to being a general classfile writer.          */

--KK

On 10/30/2012 9:49 PM, Mike Cowlishaw wrote:

>> I wouldn't be too optimistic about that - NetRexx generates Java byte
>> code and loads it in order to interpret programs.
> That's news to me ... :-)
>
> Mike
>
>
>
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>
>
>

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Mike Cowlishaw
In reply to this post by christel.u.w.pachl christel.u.w.pachl


> ----- Walter -----
> It translates to Java which is then compiled....
> That much I think (even) I know :-)
> Walter

That's how NetRexx compiles programs, not how it interprets them.

> ---- Robert Hamilton <[hidden email]> schrieb:
> > Well, Mike, how does NetRexx process programs?

Each clause is the program is represented by an object; that object has methods
which will either emit Java code (for later compilation) or execute the clause
(for interpretation).  See: NetRexxI.pdf for more details.

A third method could be added to all the clause classes to emit bytecodes (which
could then be written out as class files using RxProxy or something like it),
but those methods never got written...

Mike

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Jason Martin
In reply to this post by Jason Martin
A third method could be added to all the clause classes to emit bytecodes ....

I will work on just getting it up and running for now but byte code might be a little to deep for my head right now.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

George Hovey-2
In reply to this post by Mike Cowlishaw
Mike & all,
Here is a bookmarked version of NetRexxI.pdf with change permission granted.


It seems to me this document should be included at our site, as it gives the more sophisticated potential user a sense of the level of address underlying NetRexx, i.e. that it's not slapped together with YACC by feverish 20-somethings.

IMO its final tagline should be our motto and appear on page 1 of the site:

"Strong typing doesn't need extra typing"


On Wed, Oct 31, 2012 at 5:46 AM, Mike Cowlishaw <[hidden email]> wrote:


> ----- Walter -----
> It translates to Java which is then compiled....
> That much I think (even) I know :-)
> Walter

That's how NetRexx compiles programs, not how it interprets them.

> ---- Robert Hamilton <[hidden email]> schrieb:
> > Well, Mike, how does NetRexx process programs?

Each clause is the program is represented by an object; that object has methods
which will either emit Java code (for later compilation) or execute the clause
(for interpretation).  See: NetRexxI.pdf for more details.

A third method could be added to all the clause classes to emit bytecodes (which
could then be written out as class files using RxProxy or something like it),
but those methods never got written...

Mike

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




--
"One can live magnificently in this world if one knows how to work and how to love."  --  Leo Tolstoy

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Jason Martin
In reply to this post by Jason Martin
/* Working except access to constructor not allowed (More reading) */
/* Need to patch NetRexxC for java home lib classpath Fix java.version*/
/* Need to fix -savelog; will need for gui viewing errors NetRexxC.log */
/* Fix ecj from within NetRexxC instead of my non-Java-ness */
/* Add -errorlog to ecj args - will need for gui viewing */
/* Do the whole every file in the universe and then some thing. */
/* 24 hours straight - I'm tired now */
/* Your code not mine Jason Martin [hidden email] */

package com.agrellum.annetrexx

import android.os.Bundle
import android.app.Activity
import android.view.View
import android.view.Menu
import android.widget.Button
import android.widget.TextView
import android.os.Environment
import android.content.Context
import java.io.FileOutputStream
import dalvik.system.DexClassLoader

class MainActivity public extends Activity implements -
    android.view.View.OnClickListener

    method onCreate( savedInstanceState=Bundle )
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_main)

        button1 = Button this.findViewById( R.id.button1 )

        button1.setOnClickListener( android.view.View.OnClickListener this )

    method onCreateOptionsMenu( menu=Menu )  returns boolean
        getMenuInflater().inflate(R.menu.activity_main, menu)
        return 1

    method onClick(v=View)

        select case v.getId()

            when R.id.button1 then this.run_code()

            otherwise nop

        end

    method run_code()

        file_name = "ostwoone"

        card_dir = Environment.getExternalStorageDirectory()

        program_code = "package com.agrellum.annetrexx;say 'Android and NetRexx now that Warped.'"

        do

            nrxFile = File( card_dir || "/" || file_name || ".nrx")

            nrxFile.createNewFile()

            file_out = FileOutputStream(nrxFile)

            file_writer = OutputStreamWriter(file_out)

            file_writer.append( CharSequence program_code )

            file_writer.close()

            file_out.close()

        catch e=Exception

            say e.getMessage()

        end

        /*System.setProperty("nrx.compiler","ecj")*/
       
        flags="-nocompile -format -keepasjava -replace -savelog -sourcedir"
       
        source_code = card_dir  || "/" || file_name || ".nrx"
       
        cmd = flags || ' ' || source_code

        org.netrexx.process.NetRexxC.main(cmd)
       
        compile_string = "-verbose -deprecation -extdirs \"\" -1.5 -bootclasspath " || -
            card_dir || "/lib/android.jar:" || -
            card_dir || "/lib/ecj.jar:" || -
            card_dir || "/lib/NetRexxR.jar:" || -
            card_dir || "/lib/dx.jar" || -
            " -classpath " || -
            card_dir || ":" || " -d " || -
            card_dir || " " || -
            card_dir || "/" || file_name || ".java"

        say compile_string

        ecjMain = org.eclipse.jdt.internal.compiler.batch.Main(PrintWriter(System.out), PrintWriter(System.err), boolean 0, null, null)
        ecjMain.compile(compile_string)

        dexing_string = [ String "--dex", -
                        "--output=" || card_dir || "/" || file_name || ".zip", -
                        card_dir || "/./" || file_name || ".class" ]
                       

        com.android.dx.command.Main.main( dexing_string )
       
        dexPath = String card_dir || "/" || file_name || ".zip"
       

        put_where_I_have_rights = getDir("files", Context.MODE_PRIVATE)

        optimizedDirectory = String put_where_I_have_rights
       
        cl = DexClassLoader( dexPath, optimizedDirectory, null, getClassLoader() )

        do

            dexed_class = cl.loadClass( file_name )

            instance = dexed_class.newInstance()

            System.err.println( instance.toString() )

        catch e=Exception

            say e.getMessage()

            /* Not allowed at moment; where am i; who am i; what am i?*/

        end

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Jason Martin
Android Manifest needs use write to sdcard permission

add to Android depends libs (Special NetRexxC.jar) , ecj.jar, dx.jar on top of what's on the sdcard.

On Thu, Nov 1, 2012 at 1:25 AM, Jason Martin <[hidden email]> wrote:
/* Working except access to constructor not allowed (More reading) */
/* Need to patch NetRexxC for java home lib classpath Fix java.version*/
/* Need to fix -savelog; will need for gui viewing errors NetRexxC.log */
/* Fix ecj from within NetRexxC instead of my non-Java-ness */
/* Add -errorlog to ecj args - will need for gui viewing */
/* Do the whole every file in the universe and then some thing. */
/* 24 hours straight - I'm tired now */
/* Your code not mine Jason Martin [hidden email] */

package com.agrellum.annetrexx

import android.os.Bundle
import android.app.Activity
import android.view.View
import android.view.Menu
import android.widget.Button
import android.widget.TextView
import android.os.Environment
import android.content.Context
import java.io.FileOutputStream
import dalvik.system.DexClassLoader

class MainActivity public extends Activity implements -
    android.view.View.OnClickListener

    method onCreate( savedInstanceState=Bundle )
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_main)

        button1 = Button this.findViewById( R.id.button1 )

        button1.setOnClickListener( android.view.View.OnClickListener this )

    method onCreateOptionsMenu( menu=Menu )  returns boolean
        getMenuInflater().inflate(R.menu.activity_main, menu)
        return 1

    method onClick(v=View)

        select case v.getId()

            when R.id.button1 then this.run_code()

            otherwise nop

        end

    method run_code()

        file_name = "ostwoone"

        card_dir = Environment.getExternalStorageDirectory()

        program_code = "package com.agrellum.annetrexx;say 'Android and NetRexx now that Warped.'"

        do

            nrxFile = File( card_dir || "/" || file_name || ".nrx")

            nrxFile.createNewFile()

            file_out = FileOutputStream(nrxFile)

            file_writer = OutputStreamWriter(file_out)

            file_writer.append( CharSequence program_code )

            file_writer.close()

            file_out.close()

        catch e=Exception

            say e.getMessage()

        end

        /*System.setProperty("nrx.compiler","ecj")*/
       
        flags="-nocompile -format -keepasjava -replace -savelog -sourcedir"
       
        source_code = card_dir  || "/" || file_name || ".nrx"
       
        cmd = flags || ' ' || source_code

        org.netrexx.process.NetRexxC.main(cmd)
       
        compile_string = "-verbose -deprecation -extdirs \"\" -1.5 -bootclasspath " || -
            card_dir || "/lib/android.jar:" || -
            card_dir || "/lib/ecj.jar:" || -
            card_dir || "/lib/NetRexxR.jar:" || -
            card_dir || "/lib/dx.jar" || -
            " -classpath " || -
            card_dir || ":" || " -d " || -
            card_dir || " " || -
            card_dir || "/" || file_name || ".java"

        say compile_string

        ecjMain = org.eclipse.jdt.internal.compiler.batch.Main(PrintWriter(System.out), PrintWriter(System.err), boolean 0, null, null)
        ecjMain.compile(compile_string)

        dexing_string = [ String "--dex", -
                        "--output=" || card_dir || "/" || file_name || ".zip", -
                        card_dir || "/./" || file_name || ".class" ]
                       

        com.android.dx.command.Main.main( dexing_string )
       
        dexPath = String card_dir || "/" || file_name || ".zip"
       

        put_where_I_have_rights = getDir("files", Context.MODE_PRIVATE)

        optimizedDirectory = String put_where_I_have_rights
       
        cl = DexClassLoader( dexPath, optimizedDirectory, null, getClassLoader() )

        do

            dexed_class = cl.loadClass( file_name )

            instance = dexed_class.newInstance()

            System.err.println( instance.toString() )

        catch e=Exception

            say e.getMessage()

            /* Not allowed at moment; where am i; who am i; what am i?*/

        end


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

Mike Cowlishaw
In reply to this post by George Hovey-2
 

 
Mike & all,
Here is a bookmarked version of NetRexxI.pdf with change permission granted.

 
George, I did not give you or anyone else permission to put my document on a different site, and I certainly do not want it changed.  Please remove it.

It seems to me this document should be included at our site, as it gives the more sophisticated potential user a sense of the level of address underlying NetRexx, i.e. that it's not slapped together with YACC by feverish 20-somethings. 
 
Maybe. 

IMO its final tagline should be our motto and appear on page 1 of the site:

"Strong typing doesn't need extra typing"

Feel free to use that.
 
Mike 

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: NetRexxC working on Android very close!

George Hovey-2
Mike,
Done.

On Thu, Nov 1, 2012 at 3:43 AM, Mike Cowlishaw <[hidden email]> wrote:
 

 
Mike & all,
Here is a bookmarked version of NetRexxI.pdf with change permission granted.

 
George, I did not give you or anyone else permission to put my document on a different site, and I certainly do not want it changed.  Please remove it.

It seems to me this document should be included at our site, as it gives the more sophisticated potential user a sense of the level of address underlying NetRexx, i.e. that it's not slapped together with YACC by feverish 20-somethings. 
 
Maybe. 


IMO its final tagline should be our motto and appear on page 1 of the site:

"Strong typing doesn't need extra typing"

Feel free to use that.
 
Mike 

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/





--
"One can live magnificently in this world if one knows how to work and how to love."  --  Leo Tolstoy

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

12