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

4
  • 7
    The gibberish in notepad++ is the compiled code. It's in binary. Commented Dec 21, 2014 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. Commented Dec 21, 2014 at 23:21
  • Is it about searching for a tool? Commented Dec 21, 2014 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. Commented Feb 19, 2019 at 15:54

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Oh, This is what I am looking for. Thank you. Unfortunately, I am using Netbeans.
Netbeans also has a decompiler I dont know what version you have .But you can find ont on plugins.netbeans.org/plugin/1177/nbjad
Oh I'll check it out.
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.

1 Comment

Thank you for your help. Sadly I can't vote up.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.