[concurrency-interest] question about java.lang.reflect

David Holmes dcholmes at optusnet.com.au
Sun Mar 25 19:58:17 EDT 2007


If the member is non-public then there are synchronized sections to check
cached security credentials. Otherwise there is no real use of
synchronization that I can see. Note that the reflection mechanism also uses
dynamically generated code to speed up invocations.

David Holmes
  -----Original Message-----
  From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Dhanji R.
Prasanna
  Sent: Monday, 26 March 2007 9:37 AM
  To: concurrency-interest
  Subject: [concurrency-interest] question about java.lang.reflect


  Hi

  I am curious if the reflection classes do any synchronization?
Particularly, I have got multiple threads using the same Field (and Method)
to mutate thread-local objects of the same class. The Fields and Methods are
introspected only once (and cached in "final" members) before any other
threads have access to them.

  But does Field or Method have a critical section that may be a chokepoint?
If so, am I better off constructing a synthetic class to mutate the objects
at runtime? I know the latter would be faster, but I am curious if it is
faster due to the fact that it's a static invocation, rather than a
synchronization chokepoint.
  Thanks,

  Dhanji.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070326/ea80b640/attachment.html 


More information about the Concurrency-interest mailing list