A Very Bad BUG!

The following code cannot be run in JNode:

import java.util.ArrayList;
public class Hello {
public static void main(String[] argv){
ArrayList l = new ArrayList();
String[] v = (String[])l.toArray(new String[]{});

The result is this:

org.jnode.vm.VmSystem!getClass (245 [#getVmClass 256])
org.jnode.vm.VmSystem!arrayCopy (603 [java.lang.Object#getClass 21])
java.util.ArrayList!toArray (297 [java.lang.System#arraycopy 161])

I think this is a very bad bug because tha pattern where it fails (l.toArray(new String[]{})) it is very commonly used in post jdk 1.2 code.

Please help!

When I use the toArray method

When I use the toArray method in ArrayList on the sun JSDK I always use:

String[] v = new String[l.size()];

So try if this works, I think it throws an NPE becourse your String[] length is 0, it should allocate a new Array of the same type.

java.lang.reflect.Array bug


I didn't known this construction. It is a bug in java.lang.reflect.Array. I'll try to fix it soon.


Array.createObjectArray ALWAYS return null

Even if dim!=0, it return null

That's very strange that we never seen it before (I think we often allocate array with size greater that zero).



It is so, because a certain method in java.lang.reflect.Array is not implemented, it simply returns null. (Can you imagine that? Smiling and so many things work in JNode without it... Smiling)
I did a fix for that but it thorws SecurityEception in some cases (in other cases just works fine, and makes Java compilation under JNode possible). I would like to fix that before commiting it.


java compilation under JNode ?

Hi levente,

Are you trying compiling under JNode (I talk about source code compilation, not bytecode compilation) ?

I try to integrate Ant but I needed to add the tools.jar from jdk. Do you know if there is replacement in Classpath or kjc or any other gnu/lgpl project ?

What security exception do you have ? Is this because you try to allocate the array ? I guess this is probably a JNodePermission.



Hi Fabien!

Obviously I mean compiling Java sources under JNode with kjc.
I tried the tools.jar (well a stripped down version), for instance the jar tool works fine however I don't know about replacement for this but we can keep searching. We might describe the steps those interested should perform to get jar from Sun work under JNnode for themselves, until we have something better.
The point is to remove the classes from tools.jar that you don't need until it gets small enough for JNode to handle it under a certain heap block size setting.

Yes it's a security exception and I get an other one in the charva editor even if I use PriviledgedAction (I dont' see yet why). I want to look at these again tonight.


tools.jar, PriviledgedAction

About tools.jar :
I used tools.jar from a hard drive partition not as a plugin.
When calling ant under JNode, I had very strange and unpredictable results : JNode hangs, or the idle thread has classcastexception, ...
I think it's because tools.jar (from jdk) is not compatible with JNode and/or with Ant.

About PriviledgedAction:
I had the same problem than you. I don't know if I misunderstood the security spec or if there are bugs in our implementation.

In my situation, with 2 plugins : one for a shell command (AntCommand) and one for the library (ant.jar) used the by the command.
I kept the PriviledgedAction and copyed the same permissions in the 2 plugin descriptors and it works. It's only a temporary solution.