Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > IllegalAccessException on public method

Reply
Thread Tools

IllegalAccessException on public method

 
 
mike
Guest
Posts: n/a
 
      07-10-2004
Can some Java guru out there please explain this to me?

When using Method.invoke to call method m on an object of class Y, I
got an IllegalAccessException with the message 'Class X can not access
a member of class Y with modifiers "public"'

Class Y is a public class and its method m is a public method. I
verified the behavior with both Java 1.4.0 and Java 1.3.1. I thought
it was impossible to get an IllegalAccessException on a public method!

There's more: When I made the *constructor* of class Y public (it had
been package access), no exception was thrown and I was able to call
method m successfully using Method.invoke.

What sense does that make?

Thanks for any explanation you can give,
--Mike
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      07-10-2004
On 10 Jul 2004 12:29:14 -0700, mike wrote:

> Can some Java guru out there please explain this to me?
>
> When using Method.invoke to call method m


What method?

>..on an object of class


What class?

>...Y, I
> got an IllegalAccessException with the message 'Class X can not access
> a member of class Y with modifiers "public"'


Was it 'public static', or just 'public'?

> There's more: When I made the *constructor* of class Y public (it had
> been package access), no exception was thrown and I was able to call
> method m successfully using Method.invoke.


That would seem to fit that the
method 'm' was not declared static.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
 
 
 
Liz
Guest
Posts: n/a
 
      07-10-2004
Provide your actual code, with all the 'x', 'y', 'method', etc. who knows
what is going on.


"mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> Can some Java guru out there please explain this to me?
>
> When using Method.invoke to call method m on an object of class Y, I
> got an IllegalAccessException with the message 'Class X can not access
> a member of class Y with modifiers "public"'
>
> Class Y is a public class and its method m is a public method. I
> verified the behavior with both Java 1.4.0 and Java 1.3.1. I thought
> it was impossible to get an IllegalAccessException on a public method!
>
> There's more: When I made the *constructor* of class Y public (it had
> been package access), no exception was thrown and I was able to call
> method m successfully using Method.invoke.
>
> What sense does that make?
>
> Thanks for any explanation you can give,
> --Mike



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments