Hello,
I'm new to XMLEncoder and trying to grasp it's basics.
This works fine:
###############################################################
import java.beans.*;
import java.io.*;
public class TestIntegrated
{
private int value;
public TestIntegrated(){
value = 0;
}
public int getValue(){ return value; }
public void setValue(int value){ this.value = value; }
public static void main(String[] args)
throws FileNotFoundException{
TestIntegrated t = new TestIntegrated();
t.setValue(5);
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Test.xml"))
);
e.writeObject(t);
e.close();
}
}
###############################################################
If I split this in two Classes, it won't work anymore.
The error message is:
java.lang.IllegalAccessException: Class sun.reflect.misc.Trampoline
can not access a member of class Test with modifiers "public"
Continuing ...
java.lang.Exception: XMLEncoder:
discarding statement XMLEncoder.writeObject(Test);
Continuing ...
code:
###############################################################
import java.io.*;
class Test implements Serializable{
private int value;
public Test(){
value = 0;
}
public int getValue(){ return value; }
public void setValue(int value){ this.value = value; }
}
###############################################################
import java.beans.*;
import java.io.*;
public class TestMain
{
public static void main(String[] args) throws FileNotFoundException{
Test t = new Test();
t.setValue(5);
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Test.xml"))
);
e.writeObject(t);
e.close();
}
}
################################################################
Any Ideas why this won't work? I'm using java version 1.5.0_09.
Thanks, Manuel Kasten
Andrew Thompson - 05 Jan 2007 18:03 GMT
> java.lang.IllegalAccessException: Class sun.reflect.misc.Trampoline
> can not access a member of class Test with modifiers "public"
...
> class Test implements Serializable{
public class Test implements Serializable{
> Any Ideas why this won't work? ...
Just a WAG.
Andrew T.
Manuel Kasten - 06 Jan 2007 01:56 GMT
Andrew Thompson schrieb:
>> java.lang.IllegalAccessException: Class sun.reflect.misc.Trampoline
>> can not access a member of class Test with modifiers "public"
[quoted text clipped - 8 lines]
>
> Andrew T.
Of course. Was obvious the moment I saw it.
Thank you very much, works now.
Manuel Kasten