001-Eclipse, idea integrated javap to view bytecode

I. Overview

  A good helper for analyzing the characteristics of the java language is to use the javap tool to view the compiled bytecode of java. How to configure the javap tool in eclipse to quickly view the java bytecode.

2. Eclipse integrates javap to view bytecode

  The maven structure for code engineering. The default java compiled class file is placed under: project directory /target/classes

  First go to run -> External Tool -> External Tools Configurations and then right-click "New" after the Program node is selected to create a new extension tool configuration.

     

  Then configure it as shown below:

    

  Location: Specify the absolute path of javap.

  Working Directory: The ${project_loc} variable returns the absolute path where the project is located.

  Arguments: Pay attention to the parameter configuration here. -classpath specifies the directory where the class file is stored after the java code is compiled. Here we configure the relative directory path of the class file relative to the project root directory. The value after the -c parameter is Specifies which file's bytecode to view, and the ${java_type_name} variable returns the name of the class file you selected. Before using the javap tool, you must obtain the class file, so let your code run normally.

  If your project is not in the maven directory structure, you can only specify the relative path where your class files are stored by modifying the value of the classpath parameter according to the configuration in this article. When using the javap tool, remember to activate your current java code editing window to use it.   Example of
parameter verbose     Normal bin project: -verbose -classpath bin -c ${java_type_name}     Maven project: -verbose -classpath target/test-classes -c ${java_type_name}


Three, idea configuration view bytecode

1. Open File→Settings→Tools→External Tools;

2. Add on the right side, the configuration is as follows:

  

  name: any

  Program:javap路径【D:\ProgramFiles\Java\jdk1.8.0_121\bin\javap.exe】

  Parameters: -c $FileClass$ [same as above]   

  Working direstory:$OutputPath$

Use: Right-click on the code → External Tools to select   

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324409775&siteId=291194637