• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reflection problem - isAccessible
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reflection problem - isAccessible


  • Subject: Re: Reflection problem - isAccessible
  • From: Mike Schrag <email@hidden>
  • Date: Tue, 4 Jan 2011 12:12:52 -0500

if you Main.class.getMethod("yourMethod").setAccessible(true)
it will probably work

On Jan 4, 2011, at 12:11 PM, John Huss wrote:

Ok, so it's use in WOWSDDRegistrar.getDeclaredMethodsForClass is incorrect then, and that's why I can't create a Document style web service.  I love WO 5.4!  I'll file a radar.

Thanks,
John

On Tue, Jan 4, 2011 at 11:03 AM, Mike Schrag <email@hidden> wrote:
I don't think that means what you think it does ... isAccessible only returns true if you setAccessible, which tells the VM to skip VM security checks when you call the method.

You might want Modifier.isPublic(method.getModifiers()) ?

ms

On Jan 4, 2011, at 11:58 AM, John Huss wrote:

Does anyone know why this code doesn't print anything?

import java.lang.reflect.Method;

public class Main {

public static void main(String[] args) {
for (Method method : Main.class.getDeclaredMethods()) {
if (method.isAccessible()) {
System.out.println(method.getName());
}
}
}

}

I would expect it to print "main" since there is one public method named "main" in class Main.  Isn't that what isAccessible does?

John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)

This email sent to email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reflection problem - isAccessible
      • From: John Huss <email@hidden>
References: 
 >Reflection problem - isAccessible (From: John Huss <email@hidden>)
 >Re: Reflection problem - isAccessible (From: Mike Schrag <email@hidden>)
 >Re: Reflection problem - isAccessible (From: John Huss <email@hidden>)

  • Prev by Date: Re: Reflection problem - isAccessible
  • Next by Date: Re: Reflection problem - isAccessible
  • Previous by thread: Re: Reflection problem - isAccessible
  • Next by thread: Re: Reflection problem - isAccessible
  • Index(es):
    • Date
    • Thread