aspose file tools*
The moose likes Java in General and the fly likes Protected method access problem 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 problem" Watch "Protected method access problem" New topic
Author

Protected method access problem

Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
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


..............................<br />Exceptions are a part of possibility<br />Errors are a part of truth<br />................................
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What *exact* error message do you get?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
hats what the problem is....I get no errors
and niether does the program gets executed
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
Which method is the setNewCli("Some String"); invocation in?
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Which class and *How* did you execute?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
Class N is executed
Rohan Kalbhor
Ranch Hand

Joined: Aug 18, 2006
Posts: 78
Campbell,
i am invoking setnewcli from class N which is defined in M
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

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

Joined: Oct 13, 2005
Posts: 40064
    
  28
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

Joined: Aug 18, 2006
Posts: 78
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

Joined: Oct 13, 2005
Posts: 40064
    
  28
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

Joined: Aug 18, 2006
Posts: 78
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

Joined: Sep 29, 2002
Posts: 1683
I really think it would help if you posted the whole of the code for classes M and N.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
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

Joined: Apr 20, 2006
Posts: 3355

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

Joined: Aug 18, 2006
Posts: 78
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

Joined: Aug 18, 2006
Posts: 78
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

Joined: Oct 13, 2005
Posts: 40064
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protected method access problem