Whatever visibility class B has of A will go to whatever class is using B. The protected nature of the A constructor is not an issue for C, if C has public access to B, then A effectively has protected access to the A constructor too. The access is class defined, not object defined.

At 11:43 AM 2/24/03 -0600, you wrote:

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:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 5:35 PM
To: [EMAIL PROTECTED]
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:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 5:29 PM
To: '[EMAIL PROTECTED]'
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:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 4:56 PM
To: '[EMAIL PROTECTED]'
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: '[EMAIL PROTECTED]'
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



LEGAL NOTICE


This electronic mail transmission and any accompanying documents contain information belonging to the sender which may be confidential and legally privileged. This information is intended only for the use of the individual or entity to whom this electronic mail transmission was sent as indicated above. If you are not the intended recipient, any disclosure, copying, distribution, or action taken in reliance on the contents of the information contained in this transmission is strictly prohibited. If you have received this transmission in error, please delete the message. Thank you




Reply via email to