Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Protected Method access

 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jeremy Botha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not simply extend the class in A.jar ?

protected methods are available to subclasses.

J
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Topicis going on with refernce to the same problem
 
Yelamuri Chandu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From your ref. link doent talk about the jave access modifier "protected"

That is different and this is different.
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using Java Web Start
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest that you post the code for the superclass and the subclass.
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/384371/java/java/Protected-method-access
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
superclass


subclass


i am invoking setJCLI from another class...but setNewCallID of CTILightAdaptor is not getting invoked..!!
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic