2

I have this ClassParent class

class ClassParent<T> {

    public void set(T t)
    {
         //setter code 
    }
}

Then I have this ClassChild extending the ClassParent

class ClassChild extend ClassParent<String> {

    public void set(String str)
    {
         //setter code
    }
}

Instantiating a new instance of ClassChild class.

ClassParent<String> child = new ClassChild();

Clearly, to preserve polyporphism, java compiler will create a bridge method in the ClassChild class. My question is, after I compiled the code using javac command, I want to see how the compiled code looks like, but I don't know how to do it. I opened the .class file using NotePad++, but I just saw gibberish. How do I view the compiled code is my question. I am new to programming in general. Thank you

Trash Can
  • 6,608
  • 5
  • 24
  • 38
  • 7
    The gibberish in notepad++ _is_ the compiled code. It's in binary. – Colonel Thirty Two Dec 21 '14 at 23:18
  • Probably my question made me look dumb. I know it is the compiled code, but I have read several posts, and I saw people posted compiled codes that did not look like what I saw, I only saw black squares in Notepadd++ for the most part. – Trash Can Dec 21 '14 at 23:21
  • Is it about searching for a tool? – Paul Vargas Dec 21 '14 at 23:27
  • This is a perfectly legit question, marked as duplicate, with two question suggestions. But, one of the two suggested questions is marked as off topic. The other suggested question itself is marked as duplicate. Its suggested question is marked as off topic. If I could vote where to do it, I would mark this question not as closed duplicate and let it stand on its own. Both the question and the suggested answer below are helpful. – Amrinder Arora Feb 19 '19 at 15:54

2 Answers2

5

Use a Decompiler.If you are using Eclipse install JADClipse or look at this for a standalone version. http://jd.benow.ca/ You can also use Javap for disassembling the class file http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html

Abhijeet Kushe
  • 2,477
  • 3
  • 26
  • 39
3

If you want to see a disassembly of the compiled class, javap may be the way to go. See here: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html

If you are looking for intermediate code, used by the compiler during compilation, there is no possibility I know of to see that.

thst
  • 4,592
  • 1
  • 26
  • 40