Декомпиляция и правка приложения на JAVA

инна
Offline
Зарегистрирован: 26.12.2018

Здравствуйте, уважаемые форумчане ARDUINo.RU. у меня появился такой вопрос? Есть у меня вот такое приложение создания анимации в проекте 3D RGB LED GLOBE POV 40x200. называетcя это приложение GlobeSimulator V0.5. для того что бы с ним работать,необходимо его декомпилировать. при попытке открыть вот такой декомпилятор FernFlowerUI3.4.2.1. при попытке открыть файлы с расширением jar, он сразу перезагружается и опять открывается и ничего более не происходит, появляются только 3 строки в разделе OUTPUT., The decompling output is shown here, The output is shown in the lines of the List View,  But you can change the way it displays according to need. файликfernflower.jar  я поместила в папку FernFlowerUI. а задача такая. в GlobeSimulator.jar есть строка для написания текста, она позволяет писать символы только в одну строку. хотелось бы сделать так что бы можно было писать в 2 строки. не подскажете как настроить декомпилятор и как поправить GlobeSimulator V0.5? так как у меня нет ни каких облачных хранилищ, то если кому интересно будет я скину данные глобуса симулятора куда укажете. спасибо за понимание. жду помощи, кому не жалко помочь.

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

а WIN случайно не 32-х битная?

PS от разрядности винды не зависит, под 32 битной декомпилируется

b707
Offline
Зарегистрирован: 26.05.2017

инна - вы правда думаете, что после декомпиляции увидите в выводе какой-то код. который можно редактировать? - боюсь вы будете сильно разочарованы

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

какой-то код однозначно будет...

у меня после декомпиляции:
config.java
 

package main;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;

public class Config {
      private static Config instance = null;
      private Properties confPropsDefaults = new Properties();
      private Properties confProps;
      HashMap subscribers;

      private Config() {
            this.confProps = new Properties(this.confPropsDefaults);
            this.subscribers = new HashMap();
            this.setDefaults();
      }

      public static Config getInstance() {
            if (instance == null) {
                  instance = new Config();
            }

            return instance;
      }

      private void setDefaults() {
            this.confPropsDefaults.setProperty("nX", "200");
            this.confPropsDefaults.setProperty("nY", "40");
            this.confPropsDefaults.setProperty("nPixel", "0");
            this.confPropsDefaults.setProperty("colorDepth", "8");
            this.confPropsDefaults.setProperty("sphereSize", "1");
            this.confPropsDefaults.setProperty("lightSourceBrightness", "0.5");
            this.confPropsDefaults.setProperty("ledBrightness", "2.5");
            this.confPropsDefaults.setProperty("rotSpeed", "10000");
            this.confPropsDefaults.setProperty("freeMove", "0");
      }

      public void loadProperties(String filename) {
            try {
                  FileInputStream propInFile = new FileInputStream(filename);
                  this.confProps.load(propInFile);
                  this.confProps.list(System.out);
            } catch (FileNotFoundException var3) {
                  System.err.println("Can’t find " + filename);
            } catch (IOException var4) {
                  System.err.println("I/O failed.");
            }

      }

      public Properties getConfProps() {
            return this.confProps;
      }

      public void subscribe(String name, Subscriber obj) {
            this.subscribers.put(name, obj);
      }

      public void unsubscribe(String name) {
            Object getObj = this.subscribers.get(name);
            if (getObj != null) {
                  this.subscribers.remove(name);
            }

      }

      public void notifySubscribers() {
            Iterator i$ = this.subscribers.keySet().iterator();

            while(i$.hasNext()) {
                  String name = (String)i$.next();
                  this.notifySubscriber(name);
            }

      }

      public void notifySubscriber(String name) {
            Object getObj = this.subscribers.get(name);
            if (getObj != null) {
                  ((Subscriber)getObj).readSubscription();
            }

      }
}

AnimationFrame.java
 

package main;

import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.GraphicsConfiguration;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.j3d.Alpha;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.Material;
import javax.media.j3d.RotationInterpolator;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.TransparencyAttributes;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;

public class AnimationFrame extends JFrame implements Subscriber {
      private Canvas3D canvas3d;
      private SimpleUniverse universe;
      private Appearance[] sphereApps;
      private BranchGroup bGroup;
      private BoundingSphere bounds;
      private TransformGroup tg_spin;
      private AmbientLight ambLight;
      private DirectionalLight dirLight;
      private Color[] colorArray;
      private Config conf;
      private int nX;
      private int nY;
      float sphereSize;
      float lightSourceBrightness;
      float ledBrightness;
      int rotSpeed;
      int freeMove;
      private JPanel animPanel;
      private JButton closeButton;

      public AnimationFrame() {
            this.initComponents();
            this.conf = Config.getInstance();
            this.conf.subscribe("animFrame", this);
            this.readValues();
            this.colorArray = new Color[this.nX * this.nY];
            ImageIcon imageIcon = new ImageIcon("Logo_SL_Bloom_4.png");
            this.setIconImage(imageIcon.getImage());
            this.setLocationRelativeTo(this.getParent());
      }

      private void readValues() {
            Properties prop = this.conf.getConfProps();
            this.nX = Integer.parseInt(prop.getProperty("nX"));
            this.nY = Integer.parseInt(prop.getProperty("nY"));
            this.sphereSize = Float.parseFloat(prop.getProperty("sphereSize"));
            this.lightSourceBrightness = Float.parseFloat(prop.getProperty("lightSourceBrightness"));
            this.ledBrightness = Float.parseFloat(prop.getProperty("ledBrightness"));
            this.rotSpeed = Integer.parseInt(prop.getProperty("rotSpeed"));
            this.freeMove = Integer.parseInt(prop.getProperty("freeMove"));
      }

      public void readSubscription() {
            Properties prop = this.conf.getConfProps();
            float tmp = this.lightSourceBrightness;
            this.lightSourceBrightness = Float.parseFloat(prop.getProperty("lightSourceBrightness"));
            if (Math.abs(tmp - this.lightSourceBrightness) > 0.001F) {
                  this.changeLight();
            }

            tmp = this.ledBrightness;
            this.ledBrightness = Float.parseFloat(prop.getProperty("ledBrightness"));
            if (Math.abs(tmp - this.ledBrightness) > 0.001F) {
                  this.reloadAppearance(this.colorArray, this.ledBrightness);
            }

            tmp = this.sphereSize;
            this.sphereSize = Float.parseFloat(prop.getProperty("sphereSize"));
            if (Math.abs(tmp - this.sphereSize) > 0.001F) {
                  this.reloadSpheres(this.sphereSize);
            }

            tmp = (float)this.rotSpeed;
            this.rotSpeed = Integer.parseInt(prop.getProperty("rotSpeed"));
            if (tmp != (float)this.rotSpeed && this.freeMove != 1) {
                  for(int i = 0; i < this.tg_spin.numChildren(); ++i) {
                        if ("rotator".equals(this.tg_spin.getChild(i).getName()) && this.tg_spin.getChild(i) instanceof RotationInterpolator) {
                              RotationInterpolator rot = (RotationInterpolator)this.tg_spin.getChild(i);
                              rot.getAlpha().setDecreasingAlphaDuration((long)this.rotSpeed);
                        }
                  }
            }

      }

      public void init(Color[] colors) {
            this.colorArray = colors;
            this.createUniverse();
            this.createAppearance();
            this.createSpheres();
            if (this.freeMove == 0) {
                  this.createRotator();
            }

            this.createLights();
            if (this.freeMove == 1) {
                  this.createMouseInteraction();
            }

            this.bGroup.addChild(this.tg_spin);
            this.bGroup.compile();
            this.universe.getViewingPlatform().setNominalViewingTransform();
            this.universe.addBranchGraph(this.bGroup);
      }

      public void reloadAppearance(Color[] color) {
            this.colorArray = color;
            this.reloadAppearance(color, this.ledBrightness);
      }

      private void reloadAppearance(Color[] color, float scale) {
            this.colorArray = color;
            int mainIdx = 0;

            for(int colIdx = 0; colIdx < this.nX; ++colIdx) {
                  for(int rowIdx = 0; rowIdx < this.nY; ++rowIdx) {
                        Color3f sphereColor = new Color3f(color[rowIdx * this.nX + colIdx]);
                        sphereColor.scale(scale);
                        this.sphereApps[mainIdx].setColoringAttributes(new ColoringAttributes(sphereColor, 1));
                        this.sphereApps[mainIdx].getMaterial().setDiffuseColor(sphereColor);
                        this.sphereApps[mainIdx].getMaterial().setAmbientColor(sphereColor);
                        ++mainIdx;
                  }
            }

      }

      private void reloadSpheres(float scale) {
            int mainIdx = 0;

            for(int colIdx = 0; colIdx < this.nX; ++colIdx) {
                  for(int rowIdx = 0; rowIdx < this.nY; ++rowIdx) {
                        TransformGroup a = (TransformGroup)this.tg_spin.getChild(mainIdx + 1);
                        Transform3D b = new Transform3D();
                        a.getTransform(b);
                        b.setScale((double)scale);
                        a.setTransform(b);
                        ++mainIdx;
                  }
            }

      }

      public void changeLight() {
            Color3f lightColor = new Color3f(this.lightSourceBrightness, this.lightSourceBrightness, this.lightSourceBrightness);
            this.ambLight.setColor(lightColor);
            this.dirLight.setColor(lightColor);
      }

      private void createUniverse() {
            this.animPanel.removeAll();
            GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
            this.canvas3d = new Canvas3D(config);
            this.canvas3d.setSize(this.animPanel.getWidth(), this.animPanel.getHeight());
            this.animPanel.add("Center", this.canvas3d);
            this.universe = new SimpleUniverse(this.canvas3d);
            this.bGroup = new BranchGroup();
            this.bGroup.setCapability(12);
            this.bGroup.setCapability(13);
            this.bGroup.setCapability(17);
            this.bounds = new BoundingSphere(new Point3d(0.0D, 0.0D, 0.0D), 100.0D);
      }

      private void createAppearance() {
            this.sphereApps = new Appearance[this.nX * this.nY];
            int mainIdx = 0;

            for(int colIdx = 0; colIdx < this.nX; ++colIdx) {
                  for(int rowIdx = 0; rowIdx < this.nY; ++rowIdx) {
                        this.sphereApps[mainIdx] = new Appearance();
                        this.sphereApps[mainIdx].setCapability(8);
                        this.sphereApps[mainIdx].setCapability(9);
                        Material mat = new Material();
                        mat.setCapability(0);
                        mat.setCapability(1);
                        mat.setEmissiveColor(new Color3f(Color.BLACK));
                        mat.setShininess(50.0F);
                        this.sphereApps[mainIdx].setMaterial(mat);
                        ++mainIdx;
                  }
            }

            this.reloadAppearance(this.colorArray, this.ledBrightness);
      }

      private void createSpheres() {
            this.tg_spin = new TransformGroup();
            this.tg_spin.setCapability(18);
            double rho = 0.65D;
            double dphi = Math.toRadians(360.0D / (double)this.nX);
            double theta_0 = Math.toRadians(20.0D);
            double dtheta = Math.toRadians(140.0D / (double)(this.nY - 1));
            Appearance app = new Appearance();
            app.setCapability(8);
            app.setCapability(9);
            app.setColoringAttributes(new ColoringAttributes(new Color3f(Color.black), 1));
            TransparencyAttributes t_attr = new TransparencyAttributes(2, 0.2F);
            app.setTransparencyAttributes(t_attr);
            Sphere bigSphere = new Sphere(0.64F, 1, 60, app);
            bigSphere.setName("bigSphere");
            this.tg_spin.addChild(bigSphere);
            int mainIdx = 0;

            for(int colIdx = 0; colIdx < this.nX; ++colIdx) {
                  for(int rowIdx = 0; rowIdx < this.nY; ++rowIdx) {
                        Sphere sphere = new Sphere(0.008F, 1, 30, this.sphereApps[mainIdx]);
                        sphere.setName("" + (rowIdx * this.nX + colIdx));
                        Transform3D transToGlobe = new Transform3D();
                        TransformGroup tg_globe = new TransformGroup();
                        tg_globe.setCapability(17);
                        tg_globe.setCapability(18);
                        tg_globe.setName("" + (rowIdx * this.nX + colIdx));
                        double z = -1.0D * rho * Math.sin(theta_0 + (double)rowIdx * dtheta) * Math.cos((double)colIdx * dphi);
                        double x = -1.0D * rho * Math.sin(theta_0 + (double)rowIdx * dtheta) * Math.sin((double)colIdx * dphi);
                        double y = rho * Math.cos(theta_0 + (double)rowIdx * dtheta);
                        Vector3f vector = new Vector3f((float)x, (float)y, (float)z);
                        transToGlobe.setTranslation(vector);
                        transToGlobe.setScale((double)this.sphereSize);
                        tg_globe.setTransform(transToGlobe);
                        tg_globe.addChild(sphere);
                        this.tg_spin.addChild(tg_globe);
                        ++mainIdx;
                  }
            }

      }

      private void createLights() {
            Color3f lightColor = new Color3f(this.lightSourceBrightness, this.lightSourceBrightness, this.lightSourceBrightness);
            Vector3f lightDirection = new Vector3f(1.0F, -1.0F, -5.0F);
            this.dirLight = new DirectionalLight(lightColor, lightDirection);
            this.dirLight.setCapability(15);
            this.dirLight.setInfluencingBounds(this.bounds);
            this.ambLight = new AmbientLight(lightColor);
            this.ambLight.setCapability(15);
            this.ambLight.setInfluencingBounds(this.bounds);
            this.bGroup.addChild(this.ambLight);
            this.bGroup.addChild(this.dirLight);
      }

      private void createRotator() {
            Transform3D axis = new Transform3D();
            Alpha rotationAlpha = new Alpha();
            rotationAlpha.setMode(2);
            rotationAlpha.setDecreasingAlphaDuration(10000L);
            rotationAlpha.setLoopCount(-1);
            RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, this.tg_spin, axis, 0.0F, 6.2831855F);
            rotator.setName("rotator");
            rotator.setSchedulingBounds(this.bounds);
            this.tg_spin.addChild(rotator);
      }

      private void createMouseInteraction() {
            MouseRotate myMouseRotate = new MouseRotate();
            myMouseRotate.setName("mouseRotate");
            myMouseRotate.setTransformGroup(this.tg_spin);
            myMouseRotate.setSchedulingBounds(this.bounds);
            this.bGroup.addChild(myMouseRotate);
            MouseZoom mouseZoom = new MouseZoom();
            mouseZoom.setName("mouseZoom");
            mouseZoom.setTransformGroup(this.tg_spin);
            mouseZoom.setSchedulingBounds(this.bounds);
            this.bGroup.addChild(mouseZoom);
      }

      private void initComponents() {
            this.animPanel = new JPanel();
            this.closeButton = new JButton();
            this.setDefaultCloseOperation(2);
            this.setTitle("3D Simulation");
            this.addComponentListener(new ComponentAdapter() {
                  public void componentResized(ComponentEvent evt) {
                        AnimationFrame.this.formComponentResized(evt);
                  }
            });
            this.animPanel.setBorder(BorderFactory.createEtchedBorder());
            this.animPanel.setPreferredSize(new Dimension(500, 500));
            GroupLayout animPanelLayout = new GroupLayout(this.animPanel);
            this.animPanel.setLayout(animPanelLayout);
            animPanelLayout.setHorizontalGroup(animPanelLayout.createParallelGroup(Alignment.LEADING).addGap(0, 496, 32767));
            animPanelLayout.setVerticalGroup(animPanelLayout.createParallelGroup(Alignment.LEADING).addGap(0, 414, 32767));
            this.closeButton.setText("Close");
            this.closeButton.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent evt) {
                        AnimationFrame.this.closeButtonActionPerformed(evt);
                  }
            });
            GroupLayout layout = new GroupLayout(this.getContentPane());
            this.getContentPane().setLayout(layout);
            layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(this.animPanel, -1, -1, 32767).addGroup(Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, 32767).addComponent(this.closeButton))).addContainerGap()));
            layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(this.animPanel, -1, 418, 32767).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(this.closeButton).addContainerGap()));
            this.pack();
      }

      private void formComponentResized(ComponentEvent evt) {
            this.canvas3d.setSize(this.animPanel.getWidth(), this.animPanel.getHeight());
      }

      private void closeButtonActionPerformed(ActionEvent evt) {
            this.setVisible(false);
      }

      public static void main(String[] args) {
            try {
                  LookAndFeelInfo[] arr$ = UIManager.getInstalledLookAndFeels();
                  int len$ = arr$.length;

                  for(int i$ = 0; i$ < len$; ++i$) {
                        LookAndFeelInfo info = arr$[i$];
                        if ("Nimbus".equals(info.getName())) {
                              UIManager.setLookAndFeel(info.getClassName());
                              break;
                        }
                  }
            } catch (ClassNotFoundException var5) {
                  Logger.getLogger(AnimationFrame.class.getName()).log(Level.SEVERE, (String)null, var5);
            } catch (InstantiationException var6) {
                  Logger.getLogger(AnimationFrame.class.getName()).log(Level.SEVERE, (String)null, var6);
            } catch (IllegalAccessException var7) {
                  Logger.getLogger(AnimationFrame.class.getName()).log(Level.SEVERE, (String)null, var7);
            } catch (UnsupportedLookAndFeelException var8) {
                  Logger.getLogger(AnimationFrame.class.getName()).log(Level.SEVERE, (String)null, var8);
            }

            EventQueue.invokeLater(new Runnable() {
                  public void run() {
                        (new AnimationFrame()).setVisible(true);
                  }
            });
      }
}

ну и так далее, можно ли с этим работать - не знаю ))) (от слова совсем)

rkit
Offline
Зарегистрирован: 23.11.2016

b707 пишет:

инна - вы правда думаете, что после декомпиляции увидите в выводе какой-то код. который можно редактировать? - боюсь вы будете сильно разочарованы

Увидит. Это жава. Она вообще распространяется не в скомпилированном виде, а в байт-коде виртуальной машины.

negavoid2
negavoid2 аватар
Offline
Зарегистрирован: 06.05.2020

Увидит, но не обязательно, чтоб редактировать можно было. А вот просто почитать можно будет почти всегда, и даже если код обфусцирован, всё равно можно будет почитать по-человечески байт-код виртуалки.

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

а точнее, если декомпилировать, а потом собрать декомпилированное вновь будет понятно?!

при компиляции ругнулось:
Fatal Error: Unable to find package java.lang in classpath or bootclasspath

negavoid2
negavoid2 аватар
Offline
Зарегистрирован: 06.05.2020

А главный прикол в том, что всё это вышеописанное совершенно не нужно :) будьте в меру ленивыми :)

https://github.com/goepfert/GlobeSimulator

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

negavoid2 пишет:

А главный прикол в том, что всё это вышеописанное совершенно не нужно :) будьте в меру ленивыми :)

https://github.com/goepfert/GlobeSimulator

ОТОЖ ))) Осталось только скомпилировать, проверить, а потом поправить и скомпилировать вновь

iconini13ya
Offline
Зарегистрирован: 04.04.2021

b707 пишет:

инна - вы правда думаете, что после декомпиляции увидите в выводе какой-то код. который можно редактировать? - боюсь вы будете сильно разочарованы

Могу сказать в вашу пользу что недавно делал приложение для связи с Arduino по телефону ( что-то типо системы умный дом) и так получилось что пожилая бородатая часть моего тела говорила мне - залей на гит, не будь дураком - но молодой мозг твердил обратное до того момента, пока а у меня не слетела винда и не пришлось восстанавливать скомпилированный Java файл из Android Studio. А потом его еще и декомпилировать - но ради справедливости скажу - что все получилось (что-то конечно пришлось восстанавливать по памяти, но все-же). А вообще - Java декомпилируется как 2 пальца