search
HomeJavajavaTutorialHow to use IDEA to view the compiled bytecode content of java files

First write a java class StringDemo1.java

public class StringDemo1 {
   public static void main(String[] args) {
       String str1 = "aaa" + "bbb";
       System.out.println(str1);
       String str2 = "ccc";
       str2 += "ddd";
       System.out.println(str2);
   }
}

After compilation, generate the StringDemo1.class file

Use IDEA to view the contents of the compiled file:

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package jdk.java.lang.string;
public class StringDemo1 {
   public StringDemo1() {
   }
   public static void main(String[] args) {
       String str1 = "aaabbb";
       System.out.println(str1);
       String str2 = "ccc";
       str2 = str2 + "ddd";
       System.out.println(str2);
   }
}


It can be seen that the content has been decompiled by IDEA, and the bytecode content cannot be seen.

Use jclasslib decompilation tool

Search for the plug-in jclasslib bytecode viewer in IDEA, then install it and restart IDEA.

Open the StringDemo1.java file again, open View -> Show Bytecode on the IDEA menu bar, and you can see the bytecode file content:

// class version 52.0 (52)
// access flags 0x21
public class jdk/java/lang/string/StringDemo1 {
 // compiled from: StringDemo1.java
 // access flags 0x1
 public <init>()V
  L0
   LINENUMBER 8 L0
   ALOAD 0
   INVOKESPECIAL java/lang/Object.<init> ()V
   RETURN
  L1
   LOCALVARIABLE this Ljdk/java/lang/string/StringDemo1; L0 L1 0
   MAXSTACK = 1
   MAXLOCALS = 1
 // access flags 0x9
 public static main([Ljava/lang/String;)V
  L0
   LINENUMBER 11 L0
   LDC "aaabbb"
   ASTORE 1
  L1
   LINENUMBER 12 L1
   GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
   ALOAD 1
   INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
  L2
   LINENUMBER 15 L2
   LDC "ccc"
   ASTORE 2
  L3
   LINENUMBER 16 L3
   NEW java/lang/StringBuilder
   DUP
   INVOKESPECIAL java/lang/StringBuilder.<init> ()V
   ALOAD 2
   INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
   LDC "ddd"
   INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
   INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
   ASTORE 2
  L4
   LINENUMBER 17 L4
   GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
   ALOAD 2
   INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
  L5
   LINENUMBER 18 L5
   RETURN
  L6
   LOCALVARIABLE args [Ljava/lang/String; L0 L6 0
   LOCALVARIABLE str1 Ljava/lang/String; L1 L6 1
   LOCALVARIABLE str2 Ljava/lang/String; L3 L6 2
   MAXSTACK = 2
   MAXLOCALS = 3
}

JDK version mapping

##J2SE 852J2SE 751J2SE 6.050J2SE 5.049JDK 1.448JDK 1.347JDK 1.246JDK 1.145
JDK version class version

The above is the detailed content of How to use IDEA to view the compiled bytecode content of java files. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use