Loading

java虚拟机

1.javap -c 文件名 进行反编译

代码:

 1 import java.awt.*;
 2 import java.io.*;
 3 import javax.swing.*;
 4 
 5 /**
 6  * A program for viewing images.
 7  * @version 1.31 2018-04-10
 8  * @author Cay Horstmann
 9  */
10 public class ImageViewer
11 {
12    public static void main(String[] args)
13    {
14       EventQueue.invokeLater(() -> {
15          var frame = new ImageViewerFrame();
16          frame.setTitle("ImageViewer");
17          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
18          frame.setVisible(true);
19       });
20    }
21 }
22 
23 /**
24  * A frame with a label to show an image.
25  */
26 class ImageViewerFrame extends JFrame
27 {
28    private static final int DEFAULT_WIDTH = 300;
29    private static final int DEFAULT_HEIGHT = 400;
30 
31    public ImageViewerFrame()
32    {
33       setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
34 
35       // use a label to display the images
36       var label = new JLabel();
37       add(label);
38 
39       // set up the file chooser
40       var chooser = new JFileChooser();
41       chooser.setCurrentDirectory(new File("."));
42 
43       // set up the menu bar
44       var menuBar = new JMenuBar();
45       setJMenuBar(menuBar);
46 
47       var menu = new JMenu("File");
48       menuBar.add(menu);
49 
50       var openItem = new JMenuItem("Open");
51       menu.add(openItem);
52       openItem.addActionListener(event -> {
53          // show file chooser dialog
54          int result = chooser.showOpenDialog(null);
55 
56          // if file selected, set it as icon of the label
57          if (result == JFileChooser.APPROVE_OPTION)
58          {
59             String name = chooser.getSelectedFile().getPath();
60             label.setIcon(new ImageIcon(name));
61          }
62       });
63 
64       var exitItem = new JMenuItem("Exit");
65       menu.add(exitItem);
66       exitItem.addActionListener(event -> System.exit(0));
67    }
68 }
View Code

反编译结果:

 

 1 Compiled from "ImageViewer.java"
 2 public class ImageViewer {
 3   public ImageViewer();
 4     Code:
 5        0: aload_0
 6        1: invokespecial #1                  // Method java/lang/Object."<init>":()V
 7        4: return
 8 
 9   public static void main(java.lang.String[]);
10     Code:
11        0: invokedynamic #2,  0              // InvokeDynamic #0:run:()Ljava/lang/Runnable;
12        5: invokestatic  #3                  // Method java/awt/EventQueue.invokeLater:(Ljava/lang/Runnable;)V
13        8: return
14 }

todo

数据结构网站:

posted @ 2019-03-07 18:35  FishLight  阅读(222)  评论(0编辑  收藏  举报