1

We know "Java Type Erasure" mechanism modify types in our java source codes when they were compiled into .class file. But, today I use Java Decompiler to decompile a class file, it shows me the exactly same codes which I typed in the java file.

I want to know? Where is the "Java Type Erasure" mechanism? or how JD know?

The java codes:

public class C1 extends C<D>{

public C1()
{

}

public void myPrint()
{
    System.out.println("Hello C1");
}

public static void main(String[]args)
{
    System.out.println("Test");
}

}

Codes de-compiled from .class file by JD software:

import java.io.PrintStream;

public class C1 extends C<D>
{
  public void myPrint()
  {
    System.out.println("Hello C1");
  }

  public static void main(String[] args)
  {
    System.out.println("Test");
  }
}

You see, they are same, and it confused me that how "Type erasure" works?

0 Answers0