2 Replies Latest reply on Dec 18, 2003 9:29 PM by aquarius_kasuia

    IllegalAccessError while running a class with javassist.Load

    aquarius_kasuia Newbie

      I was testing javassist and I wrote a simple program.

      In this program there is a simple class and a Main. In the main I create a object of the class and I save this object in a file. And then open the file and get back the object, only it. It worked nice.
      Then I created a third file, Main2. In this file I simply use Javassist.Loader.Main to load the other Main class and call the main method, but this time things haven't worked. I get java.lang.IllegalAccessError. The StackTrace is here:

      java.lang.IllegalAccessError: class sun.reflect.GeneratedSerializationConstructorAccessor1 cannot access its superclass sun.reflect.SerializationConstructorAccessorImpl

      at sun.misc.Unsafe.defineClass(Native Method)
      at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
      at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
      at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:95)
      at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:301)
      at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1177)
      at java.io.ObjectStreamClass.access$1100(ObjectStreamClass.java:45)
      at java.io.ObjectStreamClass$3.run(ObjectStreamClass.java:343)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.io.ObjectStreamClass.(ObjectStreamClass.java:329)
      at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:249)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1010)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at Main.main(Main.java:27)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at javassist.Loader.run(Loader.java:263)
      at javassist.Loader.run(Loader.java:250)
      at javassist.Loader.main(Loader.java:234)
      at Main2.main(Main2.java:9)


      I'm very new to Javassist. I hope it is not a stupid problem.

      I'm using JBuiler 8

      The files I mentioned can be found here:
      http://fire.prohosting.com/kasuia/Car.java
      http://fire.prohosting.com/kasuia/Main.java
      http://fire.prohosting.com/kasuia/Main2.java

      Thank You