Discussion:
[Ikvm-developers] map.xml syntax
Steve Hannah
2016-03-02 00:05:04 UTC
Permalink
I'm trying to make some changes to the JDK java.lang.Throwable class. I
have followed the trail to the map.xml file that seems to provide drop-in
replacements for some classes but using XML syntax. What I'm trying to do
is remove the static initializer (cinit), and perform this initialization
lazily.

Essentially, I'm just adding a static boolean INITIALIZED field, then
created a static method named __clinit() which I call at the beginning of
each method.

Unfortunately, I seem to have done something wrong here as, when I build, I
now get this error:

[exec] fatal error IKVMC5042: Type 'java.lang.Throwable' referenced in
remap file was not found


My Throwable class (defined in XML) is shown here:

https://gist.github.com/shannah/84b307b2952a3dab42b3

The parts I added are:

<field name="INITIALIZED" sig="Z" modifiers="static" />

and

<method name="__clinit" sig="()V" modifiers="private static">
<attribute type="IKVM.Attributes.HideFromJavaAttribute"
sig="()V" />
<attribute
type="System.ComponentModel.EditorBrowsableAttribute"
sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V">
<parameter>Never</parameter>
</attribute>
<body>
<ldsfld class="java.lang.Throwable" name="INITIALIZED"
sig="Z" />
<brfalse name="notinitialized"/>
<ret/>
<label name="notinitialized"/>

<ldc_i4_1 />
<stsfld class="java.lang.Throwable" name="INITIALIZED"
sig="Z" />

<call type="IKVM.Internal.ExceptionHelper"
name="getPersistentFields" sig="()[Ljava.io.ObjectStreamField;" />
<stsfld class="java.lang.Throwable"
name="serialPersistentFields" sig="[Ljava.io.ObjectStreamField;" />
<ldc_i4_0 />
<newarr sig="Ljava.lang.StackTraceElement;" />
<stsfld class="java.lang.Throwable" name="UNASSIGNED_STACK"
sig="[Ljava.lang.StackTraceElement;" /> <ldc_i4_0 /> <newobj class="java.util.ArrayList" name="&lt;init&gt;"
sig="(I)V" />
<call class="java.util.Collections" name="unmodifiableList"
sig="(Ljava.util.List;)Ljava.util.List;" />
<stsfld class="java.lang.Throwable"
name="SUPPRESSED_SENTINEL" sig="Ljava.util.List;" />
<ret />
</body>
</method>


And I removed the <clinit> tag.

I also added calls to this __clinit() method at the beginning of each
method <body> in the class def.

Are there any obvious errors here?

Is there any way to get it to show a more descriptive error for map.xml
defined classes? Or is there a way to just generate the XML from Java
somehow?

Any pointers appreciated.

Best regards

Steve


And
--
Steve Hannah
Web Lite Solutions Corp.
Steve Hannah
2016-03-02 01:06:21 UTC
Permalink
Found the problem.

I was using the wrong syntax for calling my clinit method.
I was using <call type="java.lang.Throwable"....>
but should have been using <call class="java.lang.Throwable" ...>

Best regards

Steve
Post by Steve Hannah
I'm trying to make some changes to the JDK java.lang.Throwable class. I
have followed the trail to the map.xml file that seems to provide drop-in
replacements for some classes but using XML syntax. What I'm trying to do
is remove the static initializer (cinit), and perform this initialization
lazily.
Essentially, I'm just adding a static boolean INITIALIZED field, then
created a static method named __clinit() which I call at the beginning of
each method.
Unfortunately, I seem to have done something wrong here as, when I build,
[exec] fatal error IKVMC5042: Type 'java.lang.Throwable' referenced in
remap file was not found
https://gist.github.com/shannah/84b307b2952a3dab42b3
<field name="INITIALIZED" sig="Z" modifiers="static" />
and
<method name="__clinit" sig="()V" modifiers="private static">
<attribute type="IKVM.Attributes.HideFromJavaAttribute"
sig="()V" />
<attribute
type="System.ComponentModel.EditorBrowsableAttribute"
sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V">
<parameter>Never</parameter>
</attribute>
<body>
<ldsfld class="java.lang.Throwable" name="INITIALIZED"
sig="Z" />
<brfalse name="notinitialized"/>
<ret/>
<label name="notinitialized"/>
<ldc_i4_1 />
<stsfld class="java.lang.Throwable" name="INITIALIZED"
sig="Z" />
<call type="IKVM.Internal.ExceptionHelper"
name="getPersistentFields" sig="()[Ljava.io.ObjectStreamField;" />
<stsfld class="java.lang.Throwable"
name="serialPersistentFields" sig="[Ljava.io.ObjectStreamField;" />
<ldc_i4_0 />
<newarr sig="Ljava.lang.StackTraceElement;" />
<stsfld class="java.lang.Throwable" name="UNASSIGNED_STACK"
sig="(I)V" />
<call class="java.util.Collections" name="unmodifiableList"
sig="(Ljava.util.List;)Ljava.util.List;" />
<stsfld class="java.lang.Throwable"
name="SUPPRESSED_SENTINEL" sig="Ljava.util.List;" />
<ret />
</body>
</method>
And I removed the <clinit> tag.
I also added calls to this __clinit() method at the beginning of each
method <body> in the class def.
Are there any obvious errors here?
Is there any way to get it to show a more descriptive error for map.xml
defined classes? Or is there a way to just generate the XML from Java
somehow?
Any pointers appreciated.
Best regards
Steve
And
--
Steve Hannah
Web Lite Solutions Corp.
--
Steve Hannah
Web Lite Solutions Corp.
Loading...