axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leschke Scott-QA2775 <Scott.Lesc...@motorola.com>
Subject RE: Base Classes and java.lang.IllegalAccessException
Date Mon, 24 Feb 2003 17:43:58 GMT

No I don't need it. It's mostly a throwback from time spent doing C++ and as far as I can
tell, serve no real purpose in an abstract class. But I don't think it's the protected constructor.
I have other base classes that have protected constructors and the serialization works fine.
It seems to be a function of the package visibility of the base class. Changing the visibility
to public resolves the problem as I said.

It's possible to create an instance of a public derived class using "new B()" outside of package
scope but Axis can't seem to create it using reflection mechanisms. At least that's my impression.

Why this is the case is my question, as this seems a perfectly legal and reasonable thing
to do.

I'm hoping to investigate this more but I'm having some problems with Eclipse right now.

Scott

-----Original Message-----
From: Cory Wilkerson [mailto:cwilkerson@travelnow.com]
Sent: Friday, February 21, 2003 5:35 PM
To: axis-user@ws.apache.org
Subject: RE: Base Classes and java.lang.IllegalAccessException


Do you need to enforce/have to have that protected default constructor?  I'm getting by just
fine with base classes being appropriately serialized in my Axis application.  

-----Original Message-----
From: Leschke Scott-QA2775 [mailto:Scott.Leschke@motorola.com]
Sent: Friday, February 21, 2003 5:29 PM
To: 'axis-user@ws.apache.org'
Cc: 'Almeida, Timothy'
Subject: RE: Base Classes and java.lang.IllegalAccessException



I apologize a bit since my example doesn't show this. The methods of the base class are public
so can't they basically be thought of as being part of subclass via the extension. It works
fine outside of Axis.

Although with Java being incrementally loaded perhaps the base class isn't being loaded because
relection is being used...

abstract class A
{
   public int getSomeAttribute()
   {
      return someAttribute;
   }

   public void setSomeAttribute(int value)
   {
      this.someAttribute = value;
   }

   protected A()
   {}

   private int someAttribute = 0;
}

public class B
   extends A
{
   public B()
   {
      super();
   }
}

-----Original Message-----
From: Almeida, Timothy [mailto:timothya@firepond.com]
Sent: Friday, February 21, 2003 5:12 PM
To: Scott Leschke
Subject: RE: Base Classes and java.lang.IllegalAccessException


Doesn't surprise me very much. I would say, the BeanSerializer is iterating
through all the getters/setters and attempting to call them. Clearly, since
it isn't in the same package it will fail when trying to execute methods of
private classes. If reflection weren't being used to invoke those methods,
the compiler would have caught the 'illegal access'. One might say its an
Axis bug in that it does not trap and ignore such exceptions; probably is
not a bug that it cannot invoke protected methods, though.

-----Original Message-----
From: Leschke Scott-QA2775 [mailto:Scott.Leschke@motorola.com]
Sent: Friday, February 21, 2003 4:56 PM
To: 'axis-user@ws.apache.org'
Subject: FW: Base Classes and java.lang.IllegalAccessException



I haven't seen any response to this so I'll try one more time.

Scott

-----Original Message-----
From: Leschke Scott-QA2775 
Sent: Thursday, February 20, 2003 10:03 AM
To: 'axis-user@ws.apache.org'
Subject: Base Classes and java.lang.IllegalAccessException


We're using Axis 1.0 and are having a problem with serialization using
BeanSerializer. We have a number of classes that are public and have public
default constructors but they extend abstract classes that have package
level visibility. For example:

abstract class A
{
   protected A()
   {}
}

public class B
   extends A
{
   public B()
   {
      super();
   }
}

When BeanSerializer attempts to serialize B, it throws
java.lang.IllegalAccessException because A is not public. Changing the
visibility of A to public corrects the problem. Is this an artifact of Java
reflection? An Axis bug?

Thanks,

Scott

Mime
View raw message