• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Protected method access problem

 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

i have a class


I have another class



The code is getting compiled fine but class N is not able to access method setnewcli()

Can you please help me out here
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What *exact* error message do you get?
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hats what the problem is....I get no errors
and niether does the program gets executed
 
Campbell Ritchie
Sheriff
Pie
Posts: 49864
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method is the setNewCli("Some String"); invocation in?
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which class and *How* did you execute?
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class N is executed
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell,
i am invoking setnewcli from class N which is defined in M
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rohan Kalbhor:
Class N is executed


That's correct. But basically i found one minimal thing missing here in your class N to get executed.

Hint: Where does the execution of a class begins?

I suppose there ought to be a method named "main". Right?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49864
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you have a main method otherwise you would receive an error at runtime. Suggest you add the following line in the block with "setNewCLI("someString");" : "System.out.println("Called setNewCLI");//test" See whether that prints out at all.
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi cambpell,

When i added Print statement.......It got printed in N but not printing in M
--------
i am working on JDK 1.4.2_06......Is there any bug of such a kind anyone can recall about.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49864
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't look like a bug.

Have you got anything with a setCLI() method anywhere else? Have you got another class called M anywhere? Try changing "extends M" to "extends a.b.c.M".
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,
Still not helping........

I have attached the logs in here


here method allowIncomingCall is public, So it shows 'entering'(into the method) and 'leaving'
but the below two lines donot show any such things, I have printed
"Setting CLI CLI="+s
"Setting CLI CLI sent"
in N itself

This is how code in N looks
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really think it would help if you posted the whole of the code for classes M and N.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49864
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I am afraid I am not used to logs and can't use them to help your problem. Agree with Roger Chung-Wee; please post a lot more code. Please also check you only have one class M; if there is another class M anywhere you can get no end of confusion with it. Similarly check you haven't overridden the setNewCLI(String) method.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, when i tried in a simple program it did definitely work. If you wish i could paste my code here.

Otherwise, you please post your full code and it would help us resolve it better.
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, i work in a sftware firm so not possible to post the whole code...so only pasting the relevant part of it........

--------
Class N
---------
--------
Class M
--------


Please help.
 
Rohan Kalbhor
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here all methods except allowincomingcall() have the same format as setnewCLI

allowincomingcall() is



Even methods in M declared as " protected synchronized void" are getting accesed from N.It is totally an access problem.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49864
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see anything wrong with that method. Try changing "setNewCLI(jani);" to "super.setNewCLI(jani);"

I think there might be another method or something else around with the same name which has overridden your superclass method or otherwise confused the JVM.

Good luck with it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic