Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Rogue class file - Outer$1.class  (Read 1749 times)
0 Members and 2 Guests are viewing this topic.
Offline cfmdobbie

JGO Wizard
****

Posts: 1257


Who, me?


« on: 2003-04-24 03:29:38 »

Hey peeps,

Here's a bit of a wierd one for you; I'd be very grateful if anyone can give me a reason why the following happens, could tell me whether or not it's a bug, and whether it has been fixed in the latest JDK - I'm running JDK 1.4.1_01:

1  
2  
3  
4  
5  
6  
7  
8  
public class Outer
{
      private class Inner
      {
      }

      Inner i = new Inner() ;
}


When this class is compiled it produces three class files, Outer.class, Outer$Inner.class and Outer$1.class.  What is Outer$1?  It is generated whenever the class is compiled, but can be deleted without affecting the class' functionality.  When decompiling the three class files together, a single file equivalent to the above is generated - subsequently compiling this file produces the three class files again.

Decompiling just the Outer$1.class file produces the following:

1  
2  
3  
class Outer$1
{
}


Decompiling just the Outer$Inner.class file produces the following:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
private class Outer$Inner
{
      private Outer$Inner()
      {
            super();
      }

      Outer$Inner(Outer$1 outer$1)
      {
            this();
      }
}


So what is that second constructor?  Why can life continue fine without the class existing?  And is this expected behaviour?

Cheers,
Charlie.

Hellomynameis Charlie Dobbie.
Offline erikd

JGO Kernel
*****

Posts: 2561
Medals: 7


Maximumisness


« Reply #1 on: 2003-04-24 03:45:06 »

That *is* weird  Roll Eyes

When I try in Eclipse, I get the expected 2 classes (so not the Outer$1 class), but using javac I get the weird 3rd one...

Offline sma

Jr. Member
**

Posts: 98



« Reply #2 on: 2003-04-24 03:53:48 »

1.4.2 beta also generates that $1 class.  Eclipse 2.1 doesn't. The eclipse-generated Outer$Inner class has just one constructor:
1  
2  
3  
4  
Outer$Inner(Outer o) {
  super();
  this$0 = o;
}

javac probably wants to make sure to create a unique method signature but I don't really know why.

.: Truth Until Paradox!
Games published by our own members! Go get 'em!
Offline snak

JGO n00b
*

Posts: 25


Eu não falo o português


« Reply #3 on: 2003-04-24 10:36:14 »

It's a class generated to send information to the CIA.  That's why when you decompile it you dont see anything.  True story
Offline jbanes

JGO Neuromancer
****

Posts: 1178


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #4 on: 2003-04-24 11:21:20 »

It's a "go between" class that links used methods and variables between the internal and parent classes. Since your example doesn't actually access anything inside internal class or vica-versa, the "go between" is unnecessary. Javac usually generates it anyway. I'll make a bet that Eclipse is using Jikes instead.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline cfmdobbie

JGO Wizard
****

Posts: 1257


Who, me?


« Reply #5 on: 2003-04-24 14:38:59 »

Ah, good.  I won't worry about it then.

I was developing an ultra-clever DisplayMode filtering class and had a load of anonymous inner classes at one point.  I then removed them all in favour of one named inner class.  But one unnamed class file remained...

I have noticed that it doesn't appear if the inner class is anything but private though.  I must decompile the classes and see what goes on in that case.

Cheers, everyone!

Hellomynameis Charlie Dobbie.
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.076 seconds with 19 queries.