[問題] decompiler

看板java作者 ( )時間15年前 (2010/09/23 09:14), 編輯推噓1(107)
留言8則, 3人參與, 最新討論串1/1
-------------------------------------------------------------------------------- http://www.neshkov.com/dj.html 用以上的decompiler將以下網頁的class檔反編譯 http://ngsir.netfirms.com/englishhtm/RLC.htm (有RLC.class和circuit.class和signal.class三個類別檔) 我有疑問的是,這三個檔被decompile出來後的source code例如RLC.java : -- <code> import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.EventObject; public class RLC extends Applet implements AdjustmentListener, ActionListener { public RLC() { } public void init() { setBackground(Color.white); setBounds(0, 0, 750, 500); mt = new MediaTracker(this); rcl = getImage(getCodeBase(), "rcl2.gif"); formula = getImage(getCodeBase(), "formula.gif"); formula2 = getImage(getCodeBase(), "formula2.gif"); formula3 = getImage(getCodeBase(), "formula3.gif"); mt.addImage(rcl, 1); mt.addImage(formula, 2); mt.addImage(formula2, 3); mt.addImage(formula3, 4); for(int i = 1; i <= 4; i++) { try { mt.waitForID; } catch(InterruptedException interruptedexception) { } if(mt.isErrorID) return; } amplitudeScrollbar = new Scrollbar(0, 8, 0, 2, 11); frequencyScrollbar = new Scrollbar(0, 346, 0, 100, 660); RScrollbar = new Scrollbar(0, 16, 0, 10, 100); CScrollbar = new Scrollbar(0, 260, 0, 50, 500); LScrollbar = new Scrollbar(0, 250, 0, 50, 500); pause = new Button("Pause"); step = new Button("Step"); amplitudeLabel = new Label("Vo = " + String.valueOf(amplitudeScrollbar.getValue()) + " V", 2); frequencyLabel = new Label("f = " + String.valueOf(0.10000000000000001D * (double)frequencyScrollbar.getValue()) + " Hz", 2); resistanceLabel = new Label("R = " + String.valueOf(0.10000000000000001D * (double)RScrollbar.getValue()) + " Ohm", 2); capacitanceLabel = new Label("C = " + String.valueOf(2 * CScrollbar.getValue()) + " microF", 2); inductanceLabel = new Label("L = " + String.valueOf((double)Math.round(2000D * (double)LScrollbar.getValue()) / 10000D) + " mH", 2); dummy = new Label(" "); offimg = createImage(getSize().width, getSize().height); offg = offimg.getGraphics(); circuit = new Circuit(offg, offimg, rcl, formula, formula2, formula3); circuit.Vo = amplitudeScrollbar.getValue(); circuit.omega = 0.62831999999999999D * (double)frequencyScrollbar.getValue(); circuit.R = 0.10000000000000001D * (double)RScrollbar.getValue(); circuit.C = 1.9999999999999999E-006D * (double)CScrollbar.getValue(); circuit.L = 0.00020000000000000001D * (double)LScrollbar.getValue(); amplitudeScrollbar.addAdjustmentListener(this); frequencyScrollbar.addAdjustmentListener(this); RScrollbar.addAdjustmentListener(this); CScrollbar.addAdjustmentListener(this); LScrollbar.addAdjustmentListener(this); pause.addActionListener(this); step.addActionListener(this); signal = new Signal(circuit); Panel panel = new Panel(); GBC = new GridBagConstraints(); GB = new GridBagLayout(); panel.setLayout(G; GBC.fill = 2; GBC.insets = new Insets(3, 3, 3, 3); GBC.ipadx = 10; GBC.gridx = 0; GBC.gridy = 0; GB.setConstraints(amplitudeLabel, GBC); panel.add(amplitudeLabel); GBC.ipadx = 30; GBC.gridx = 1; GB.setConstraints(amplitudeScrollbar, GBC); panel.add(amplitudeScrollbar); GBC.ipadx = 30; GBC.gridx = 2; GB.setConstraints(frequencyLabel, GBC); panel.add(frequencyLabel); GBC.ipadx = 30; GBC.gridx = 3; GB.setConstraints(frequencyScrollbar, GBC); panel.add(frequencyScrollbar); GBC.ipadx = 10; GBC.gridx = 4; GB.setConstraints(pause, GBC); panel.add(pause); GBC.gridx = 5; GB.setConstraints(step, GBC); panel.add(step); GBC.gridx = 0; GBC.gridy = 1; GB.setConstraints(resistanceLabel, GBC); panel.add(resistanceLabel); GBC.gridx = 1; GB.setConstraints(RScrollbar, GBC); panel.add(RScrollbar); GBC.gridx = 2; GB.setConstraints(capacitanceLabel, GBC); panel.add(capacitanceLabel); GBC.gridx = 3; GB.setConstraints(CScrollbar, GBC); panel.add(CScrollbar); GBC.gridx = 4; GB.setConstraints(inductanceLabel, GBC); panel.add(inductanceLabel); GBC.ipadx = 30; GBC.gridx = 5; GB.setConstraints(LScrollbar, GBC); panel.add(LScrollbar); setLayout(new BorderLayout()); add(circuit, "Center"); add(panel, "South"); circuit.calculate(); signal.start(); } public void actionPerformed(ActionEvent actionevent) { if(actionevent.getSource() == pause) { circuit.pause = !circuit.pause; if(circuit.pause) { pause.setLabel("Continue"); } else { pause.setLabel("Pause"); circuit.step = false; } } if(actionevent.getSource() == step) { circuit.step = true; circuit.pause = true; pause.setLabel("Continue"); } } public void adjustmentValueChanged(AdjustmentEvent adjustmentevent) { if(adjustmentevent.getSource() == amplitudeScrollbar) { amplitudeLabel.setText("Vo = " + String.valueOf(amplitudeScrollbar.getValue()) + " V"); circuit.Vo = amplitudeScrollbar.getValue(); } if(adjustmentevent.getSource() == frequencyScrollbar) { frequencyLabel.setText("f = " + String.valueOf((1.0D * (double)frequencyScrollbar.getValue()) / 10D) + " Hz"); double d = circuit.omega; circuit.omega = 0.62831999999999999D * (double)frequencyScrollbar.getValue(); circuit.t = (d * circuit.t) / circuit.omega; } if(adjustmentevent.getSource() == RScrollbar) { resistanceLabel.setText("R = " + String.valueOf((1.0D * (double)RScrollbar.getValue()) / 10D) + " Ohm"); circuit.R = 0.10000000000000001D * (double)RScrollbar.getValue(); } if(adjustmentevent.getSource() == CScrollbar) { capacitanceLabel.setText("C = " + String.valueOf(2 * CScrollbar.getValue()) + " microF"); circuit.C = 1.9999999999999999E-006D * (double)CScrollbar.getValue(); } if(adjustmentevent.getSource() == LScrollbar) { inductanceLabel.setText("L = " + String.valueOf((double)Math.round(2000D * (double)LScrollbar.getValue()) / 10000D) + " mH"); circuit.L = 0.00020000000000000001D * (double)LScrollbar.getValue(); } circuit.calculate(); circuit.repaint(); } int xx; int yy; Label amplitudeLabel; Label frequencyLabel; Label resistanceLabel; Label capacitanceLabel; Label inductanceLabel; Label dummy; Scrollbar amplitudeScrollbar; Scrollbar frequencyScrollbar; Scrollbar RScrollbar; Scrollbar CScrollbar; Scrollbar LScrollbar; Button pause; Button step; Circuit circuit; Signal signal; Graphics offg; Image offimg; Image rcl; Image formula; Image formula2; Image formula3; MediaTracker mt; GridBagLayout GB; GridBagConstraints GBC; } </code> -- 裡頭的circuit物件應該是屬於circuit類別檔的成員,但是一開始import部分卻沒有看到 ? 是不是這個decompiler有問題,還是某種javac允許編譯過程某些物件暫時未宣告繼承來 源? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.44.115.138

09/23 09:26, , 2F
感謝樓上大大。我的問題是,單獨將RLC.java作編譯
09/23 09:26, 2F

09/23 09:27, , 3F
javac顯示circuit無效的type(因為沒有import)
09/23 09:27, 3F

09/23 09:34, , 4F
我只是告訴你,那個檔案是存在的,至於為什麼不用寫 import
09/23 09:34, 4F

09/23 09:36, , 5F
你可以再多想一下
09/23 09:36, 5F

09/23 09:41, , 6F
不好意思我是新手。現在事實上就是我用javac去執行
09/23 09:41, 6F

09/23 09:43, , 7F
作不出來
09/23 09:43, 7F

09/23 09:50, , 8F
找個applet的文件來看
09/23 09:50, 8F
文章代碼(AID): #1CcgdzUk (java)
文章代碼(AID): #1CcgdzUk (java)