aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Instantiating an anonymous class in multiple places in a program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Instantiating an anonymous class in multiple places in a program" Watch "Instantiating an anonymous class in multiple places in a program" New topic
Author

Instantiating an anonymous class in multiple places in a program

Maciek Makowski
Greenhorn

Joined: May 17, 2005
Posts: 11
A quote from JLS:


A given anonymous class is only instantiated at a single point in a program.


This does not seem to be true, since we can instantiate a class using reflection:



Am I missing something, or is JLS wrong? The problem is that the argument of "single-point instancing" was used as a rationale for a design decision (namely, that anonymous classes' instance initializers are allowed to throw any exception).
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I guess it's not totally true. But give the author a break--going into a tangent on reflection (an advanced topic) wouldn't do much good for a newbie that doesn't even understand what an anonymous class is.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Maciek Makowski
Greenhorn

Joined: May 17, 2005
Posts: 11
Well, the thing is this is a quote from the Java Language Specification, so I presume the author wasn't a Java newbie...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instantiating an anonymous class in multiple places in a program