File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Protected Method access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Protected Method access" Watch "Protected Method access" New topic
Author

Protected Method access

Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
Hi guys,

I have a class in a.jar which has a method of "protected void a()" type.
a.jar is a signed jar file.

I have another b.jar file which wants to access the method a()
but at the present it is not able to do so...i have tried all possible solutions
b.jar is unsigned.

now this is the last option i am not sure about so...i need help from you guys.

Does signing of jar makes a difference in acces of protected methods,and it is not possible to access it from an unsigned jar?


..............................<br />Exceptions are a part of possibility<br />Errors are a part of truth<br />................................
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435
    
  23

The 'protected' access specifier does not have anything to do with whether your JAR files are signed or not; signing or not signing a JAR file does not change the meaning of 'protected'.

A protected class member is accessible in the class itself, in subclasses of that class and in classes that are in the same package as the class.

What is the exact error message you are getting?
[ January 08, 2008: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jeremy Botha
Ranch Hand

Joined: Feb 16, 2005
Posts: 125
Why not simply extend the class in A.jar ?

protected methods are available to subclasses.

J


McFinnigan? Never heard of him. Nobody here but us chickens...<br /> <br />SCJP for Java 1.4<br />SCJD for Java 5.0
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
Hi jeremy,

I have tried all possible solutions.......

Chk out this link

http://www.vsj.co.uk/java/display.asp?id=247

see the 4th paragraph
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
Hi jesper,
I am getting no errors and no excpetion....

I have extended the mother class.Event the public methods are getting accesed.Only the protected methods are not getting accessed.I can understand that through the logs i get.
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
This Topicis going on with refernce to the same problem
Yelamuri Chandu
Greenhorn

Joined: Jan 08, 2008
Posts: 15
From your ref. link doent talk about the jave access modifier "protected"

That is different and this is different.
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
i am using Java Web Start
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
I suggest that you post the code for the superclass and the subclass.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
http://www.coderanch.com/t/384371/java/java/Protected-method-access
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
superclass


subclass


i am invoking setJCLI from another class...but setNewCallID of CTILightAdaptor is not getting invoked..!!
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
A few things I can think of.

1. You do not need to use super as the subclass has access by inheritance to all non-final protected methods in the superclass.

2. Are you sure that the subclass is extending the correct version of CTILightAdaptor?

3. Why do you think that setNewCallID is not being invoked. Have you added logging to this method to check for this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protected Method access