Anonymous and local class names changed in 1.5

M

Mike Schilling

Consider the Java class::

class Outer {
class Inner {
Object o = new Object() {
public String toString() { return "MYOB";}};
void method() {
class Local {}
}
}
}

In 1.4.2, there are classes Outer$1.class and Outer$1Local.class. In 1.5,
these become Outer$Inner$1.class and Outer$Inner$1Local.class. Can anyone
see a reason for this other than to annoy me (and break the tools I use to
analyze Java classes)?
 
Z

zero

Consider the Java class::

class Outer {
class Inner {
Object o = new Object() {
public String toString() { return "MYOB";}};
void method() {
class Local {}
}
}
}

In 1.4.2, there are classes Outer$1.class and Outer$1Local.class. In
1.5, these become Outer$Inner$1.class and Outer$Inner$1Local.class.
Can anyone see a reason for this other than to annoy me (and break the
tools I use to analyze Java classes)?

The 1.5 way seems more logical and natural to me. After all your anonymous
and Local classes are inside Inner inside Outer. Maybe the guys at Sun
thought so too.
 
T

Thomas Hawtin

Mike said:
In 1.4.2, there are classes Outer$1.class and Outer$1Local.class. In 1.5,
these become Outer$Inner$1.class and Outer$Inner$1Local.class. Can anyone
see a reason for this other than to annoy me (and break the tools I use to
analyze Java classes)?

The good news is the JLS3 gives rules to what the format should be, so
shouldn't change too much in the future.

Tom Hawtin
 
R

Roedy Green

In 1.4.2, there are classes Outer$1.class and Outer$1Local.class. In 1.5,
these become Outer$Inner$1.class and Outer$Inner$1Local.class. Can anyone
see a reason for this other than to annoy me (and break the tools I use to
analyze Java classes)?

A bug has been corrected.
 
M

Mike Schilling

Roedy Green said:
A bug has been corrected.

I don't see any bug. The change to local class names in 1.4.2 *was* a
bugfix, IIRC, because the previous names could be ambiguous, but the 1.4.2.
naming convention worked perfectly well.
 
R

Roedy Green

I don't see any bug. The change to local class names in 1.4.2 *was* a
bugfix, IIRC, because the previous names could be ambiguous, but the 1.4.2.
naming convention worked perfectly well.

To me they seem wrong if that description of the names is correct. A
name should reflect something's proper place in the hierarchy. (how
feudal!) In any case the designers were putting the naming rules in
the JLS so they probably decided to tidy them up to make them easier
to explain and easier to defend.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top