You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Weldon Washburn <we...@gmail.com> on 2006/02/14 02:59:23 UTC

[jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Archie,
I am working on kernel_path String.java.  It wants to call a native
method to do the intern work.  If you plan to add a native method that
does String intern, I won't spend the time doing interning in Java
code.   I think this code is related to  _jc_ilib_entry table.  Do you
have thoughts on the best approach?

Thanks

--
Weldon Washburn
Intel Middleware Products Division

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Oliver Deakin <ol...@googlemail.com>.
Hi Weldon,

Weldon Washburn wrote:
> Archie,
> I am working on kernel_path String.java.  
The only VM specific method in String currently is intern. However, 
inclusion of this method in the kernel forces the VM vendor to implement 
the rest of the String class, which has no further VM specific code.

Can we propose to move String out of kernel and into LUNI, and reroute 
Strings intern call through an intern method the VM class in kernel? 
This was mentioned in a JIRA comment made by Tim a couple of weeks ago:
http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200601.mbox/%3c1773406474.1138708234190.JavaMail.jira@ajax.apache.org%3e

So the String implementation will be held in LUNI, and its intern method 
will just make a direct call to VM.intern(String), which is in the 
kernel. This means that a VM vendor only needs to produce the intern 
method (in VM.java), and not the rest of the String class, cutting down 
the kernel size and the resulting workload for the VM vendor.

> It wants to call a native
> method to do the intern work.  If you plan to add a native method that
> does String intern, I won't spend the time doing interning in Java
> code.   I think this code is related to  _jc_ilib_entry table.  Do you
> have thoughts on the best approach?
>
> Thanks
>
> --
> Weldon Washburn
> Intel Middleware Products Division
>
>   

-- 
Oliver Deakin
IBM United Kingdom Limited


Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Geir Magnusson Jr <ge...@pobox.com>.
could it throw an Error rather than while(true)?  Much easier to debug... :)

Weldon Washburn wrote:
> On 2/14/06, Tim Ellison <t....@gmail.com> wrote:
>> Weldon Washburn wrote:
>>> Question -- does it make sense to include a stupid, simple
>>> String.intern() in the kernel class to make it even easier and more
>>> convenient for someone trying to graft Harmony Class Libraries to a
>>> new JVM?
>> Sure, we can add it to the KERNEL module stubs so people can choose to
>> reuse it or replace it as they see fit.  Care to contribute yours?
> OK. But I warn you its really stupid, really simple and... its never
> even been compiled.  Below is the code:
> 
> private String [] internArray = new String[256];
>     public String intern()
>     {
>         System.out.println("String.intern() is not fully implemented");
> 
>         for (int ii = 0; ii < internArray.length; ii++)
>         {
>             if (this.equals(internArray[ii]))
>                 return internArray[ii];
>             if (internArray[ii] == null)
>             {
>                 internArray[ii] = this;
>                 return this;
>             }
>         }
>         while (true)
>             System.out.println("String.intern() --- error, overflowed
> intern storage");
>     }
> 
> --
> Weldon Washburn
> Intel Middleware Products Division
> 
> 

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Weldon Washburn <we...@gmail.com>.
On 2/14/06, Tim Ellison <t....@gmail.com> wrote:
> Weldon Washburn wrote:
> > Question -- does it make sense to include a stupid, simple
> > String.intern() in the kernel class to make it even easier and more
> > convenient for someone trying to graft Harmony Class Libraries to a
> > new JVM?
>
> Sure, we can add it to the KERNEL module stubs so people can choose to
> reuse it or replace it as they see fit.  Care to contribute yours?
OK. But I warn you its really stupid, really simple and... its never
even been compiled.  Below is the code:

private String [] internArray = new String[256];
    public String intern()
    {
        System.out.println("String.intern() is not fully implemented");

        for (int ii = 0; ii < internArray.length; ii++)
        {
            if (this.equals(internArray[ii]))
                return internArray[ii];
            if (internArray[ii] == null)
            {
                internArray[ii] = this;
                return this;
            }
        }
        while (true)
            System.out.println("String.intern() --- error, overflowed
intern storage");
    }

--
Weldon Washburn
Intel Middleware Products Division

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Tim Ellison <t....@gmail.com>.
Weldon Washburn wrote:
> Question -- does it make sense to include a stupid, simple
> String.intern() in the kernel class to make it even easier and more
> convenient for someone trying to graft Harmony Class Libraries to a
> new JVM?

Sure, we can add it to the KERNEL module stubs so people can choose to
reuse it or replace it as they see fit.  Care to contribute yours?

Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Weldon Washburn <we...@gmail.com>.
For the initial "hello world" phase of Harmony Class Library on
JCHEVM, I wrote a real stupid, simple String intern in java.  It can
be replaced later with a more sophisticated version.

Question -- does it make sense to include a stupid, simple
String.intern() in the kernel class to make it even easier and more
convenient for someone trying to graft Harmony Class Libraries to a
new JVM?

 - Weldon


On 2/14/06, Archie Cobbs <ar...@dellroad.org> wrote:
> Tim Ellison wrote:
> > sure -- String interning is in the kernel precisely so that the VM
> > implementor (i.e. you) can choose to do it in native or Java code.
> >
> > Of course, they have to be interned into the same table as the JLS
> > string literals.
>
> Of course :-) JCHEVM handles this correctly.
>
> -Archie
>
> __________________________________________________________________________
> Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
>


--
Weldon Washburn
Intel Middleware Products Division

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Archie Cobbs <ar...@dellroad.org>.
Tim Ellison wrote:
> sure -- String interning is in the kernel precisely so that the VM
> implementor (i.e. you) can choose to do it in native or Java code.
> 
> Of course, they have to be interned into the same table as the JLS
> string literals.

Of course :-) JCHEVM handles this correctly.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Tim Ellison <t....@gmail.com>.
sure -- String interning is in the kernel precisely so that the VM
implementor (i.e. you) can choose to do it in native or Java code.

Of course, they have to be interned into the same table as the JLS
string literals.

Regards,
Tim

Archie Cobbs wrote:
> Weldon Washburn wrote:
>> I am working on kernel_path String.java.  It wants to call a native
>> method to do the intern work.  If you plan to add a native method that
>> does String intern, I won't spend the time doing interning in Java
>> code.   I think this code is related to  _jc_ilib_entry table.  Do you
>> have thoughts on the best approach?
> 
> The best approach (imho) is to do interning in Java, using a
> WeakHashMap, which is perfect for the task. The Classpath
> implementation is a mere 10 lines or so.
> 
> -Archie
> 
> __________________________________________________________________________
> Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

Re: [jchevm] native method API for _jc_new_intern_string -- do you plan to add to _jc_ilib_entry table?

Posted by Archie Cobbs <ar...@dellroad.org>.
Weldon Washburn wrote:
> I am working on kernel_path String.java.  It wants to call a native
> method to do the intern work.  If you plan to add a native method that
> does String intern, I won't spend the time doing interning in Java
> code.   I think this code is related to  _jc_ilib_entry table.  Do you
> have thoughts on the best approach?

The best approach (imho) is to do interning in Java, using a
WeakHashMap, which is perfect for the task. The Classpath
implementation is a mere 10 lines or so.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com