Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 801253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:24:51+00:00 2026-05-14T23:24:51+00:00

package com.test; public class OuterClass { public class InnerClass { public class InnerInnerClass {

  • 0
package com.test;

public class OuterClass {
    public class InnerClass {
        public class InnerInnerClass {

        }
    }

    public class InnerClass2 {

    }

    //this class should not exist in OuterClass after dummifying
    private class PrivateInnerClass {
        private String getString() {
            return "hello PrivateInnerClass";
        }
    }

    public String getStringFromPrivateInner() {
        return new PrivateInnerClass().getString();
    }
}

When run through javac on the command line with Sun JVM 1.6.0_20, this code produces 6 .class files:

OuterClass.class
OuterClass$1.class
OuterClass$InnerClass.class
OuterClass$InnerClass2.class
OuterClass$InnerClass$InnerInnerClass.class
OuterClass$PrivateInnerClass.class

When run through JDT in eclipse, it produces only 5 classes.

OuterClass.class
OuterClass$1.class
OuterClass$InnerClass.class
OuterClass$InnerClass2.class
OuterClass$InnerClass$InnerInnerClass.class
OuterClass$PrivateInnerClass.class

When decompiled, OuterClass$1.class contains nothing. Where is this extra class coming from and why is it created?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:24:51+00:00Added an answer on May 14, 2026 at 11:24 pm

    I don’t have the answer, but I’m able to confirm that, and reduce the snippet to the following:

    public class OuterClass {
        private class PrivateInnerClass {
        }
        public void instantiate() {
            new PrivateInnerClass();
        }
    }
    

    This creates OuterClass$1.class

    Compiled from "OuterClass.java"
    class OuterClass$1 extends java.lang.Object{
    }
    

    And here’s javap -c for OuterClass.class:

    Compiled from "OuterClass.java"
    public class OuterClass extends java.lang.Object{
    public OuterClass();
      Code:
       0:   aload_0
       1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
       4:   return
    
    public void instantiate();
      Code:
       0:   new     #2; //class OuterClass$PrivateInnerClass
       3:   dup
       4:   aload_0
       5:   aconst_null
       6:   invokespecial #3; //Method OuterClass$PrivateInnerClass."<init>":
                              //(LOuterClass;LOuterClass$1;)V
       9:   pop
       10:  return
    
    }
    

    And for OuterClass$PrivateInnerClass:

    Compiled from "OuterClass.java"
    class OuterClass$PrivateInnerClass extends java.lang.Object{
    final OuterClass this$0;
    
    OuterClass$PrivateInnerClass(OuterClass, OuterClass$1);
      Code:
       0:   aload_0
       1:   aload_1
       2:   invokespecial   #1; //Method "<init>":(LOuterClass;)V
       5:   return
    
    }
    

    As you can see, the synthesized constructor takes an OuterClass$1 argument.

    So javac creates the default constructor to take an extra argument, of type $1, and the value of that default argument is 5: aconst_null.


    I’ve found that $1 doesn’t get created if either of the following is true:

    • You make public class PrivateInnerClass
    • You declare a nullary constructor for PrivateInnerClass
    • Or you don’t call the new on it
    • Probably other things (e.g. static nested, etc).

    Possibly related

    • Bug ID:4295934: Compiling a private inner class creates an anonymous class file in the wrong dir

    Create the following source in a directory called test:

    package test;
    
    public class testClass
    {
        private class Inner
        {
        }
        public testClass()
        {
            Inner in = new Inner();
        }
    }
    

    Compile the file from the parent directory javac test/testClass.java

    Notice that the file testClass$1.class is created in the current directory.
    Not sure why this file is even created since there is also a test/testClass$Inner.class created as well.

    EVALUATION

    The testClass$1.class file is for a dummy class needed by an "access
    constructor" for the private constructor of the private inner class
    testClass$Inner. Dissassembly shows that the fully-qualified name of
    this class is correctly noted, so it is unclear why the class file ends
    up in the wrong directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 446k
  • Answers 446k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Alright, so it turns out that you can theoretically make… May 15, 2026 at 7:19 pm
  • Editorial Team
    Editorial Team added an answer What you will need to do is get the shell… May 15, 2026 at 7:19 pm
  • Editorial Team
    Editorial Team added an answer It seems this project has died. No new stuff to… May 15, 2026 at 7:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.