-5

i have downloaded a android game program from internet and i tried to run it gives error on Method and goto statement.

i know goto statement is not support in java.. i dont know they are any other tool or language . i want to know which technology or tool or language they are used.

this is the code

package com.infraredpixel.drop.activities;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.RectF;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.opengl.GLSurfaceView;
import android.os.*;
import android.util.Log;
import android.view.*;

import com.infraredpixel.drop.*;

import java.lang.reflect.Method;
import java.util.List;

// Referenced classes of package com.infraredpixel.drop.activities:
//            ProfilingActivity, DebugActivity, MainMenuActivity

public class OpenGLDropActivity extends Activity
{

    public OpenGLDropActivity()
    {
    }

    private int getDefaultRotation()
    {
        int i;
        WindowManager windowmanager;
        Method amethod[];
        String s;
        int j;
        i = 0;
        windowmanager = (WindowManager)getSystemService("window");
        amethod = windowmanager.getDefaultDisplay().getClass().getDeclaredMethods();
        s = new String("getRotation");
        j = amethod.length;
_L2:
        Method method = null;
        Display display;
        if(i < j)
        {
label0:
            {
                Method method1 = amethod[i];
                Log.d("Methods", method1.getName());
                if(!method1.getName().equals(s))
                    break label0;
                method = method1;
            }
        }
        display = windowmanager.getDefaultDisplay();
        if(method != null)
        {
            int k;
            try
            {
                k = ((Integer)method.invoke(display, new Object[0])).intValue();
            }
            catch(Exception exception)
            {
                return 0;
            }
            return k;
        } else
        {
            return display.getOrientation();
        }
        i++;
        if(true){ goto _L2;} else{ goto _L1;}
_L1:
    }

    protected void handleScore()
    {
        int i;
        int j;
        SharedPreferences sharedpreferences;
        int k;
        String s;
        i = (int)(0.49F + (float)_StatusManager.dropDist());
        j = (int)(0.49F + (float)_StatusManager.getStars());
        sharedpreferences = getSharedPreferences("DropSettings", 0);
        k = sharedpreferences.getInt("highScore", -1);
        s = "";
        if(2 != _ControlMode) goto _L2; else goto _L1;
_L1:
        s = "tiltHighScore";
_L4:
        int l = sharedpreferences.getInt(s, 0);
        if(i + j > k && i + j > l)
        {
            _DeathDetector.setCurrentHighScore(i + j);
            android.content.SharedPreferences.Editor editor = sharedpreferences.edit();
            editor.putInt("highScore", -1);
            editor.putInt(s, i + j);
            editor.commit();
        }
        return;
_L2:
        if(1 == _ControlMode || _ControlMode == 0)
            s = "touchHighScore";
        if(true) goto _L4; else goto _L3
_L3:
    }

    public void onCreate(Bundle bundle)
    {
        SharedPreferences sharedpreferences;
        super.onCreate(bundle);
        sharedpreferences = getSharedPreferences("DropSettings", 0);
        spriteRenderer = new GLRenderer(getApplicationContext());
        int i = sharedpreferences.getInt("fullScreenWidth", 480);
        widthPixels = i;
        int j = sharedpreferences.getInt("fullScreenHeight", 640);
        RectF rectf = new RectF(0.0F, j, i, 0.0F);
        boolean flag = sharedpreferences.getBoolean("useVibration", true);
        boolean flag1 = sharedpreferences.getBoolean("godMode", false);
        int k = sharedpreferences.getInt("ballType", 0);
        int l = Math.max(sharedpreferences.getInt("highScore", 0), Math.max(sharedpreferences.getInt("tiltHighScore", 0), sharedpreferences.getInt("touchHighScore", 0)));
        _ControlMode = sharedpreferences.getInt("controlMode", 2);
        boolean flag2 = sharedpreferences.getBoolean("testModeDropSettings", false);
        boolean flag3 = sharedpreferences.getBoolean("testModeMainSettings", false);
        DropSettingsGroup adropsettingsgroup[];
        DropManager dropmanager;
        Handler handler;
        Runnable runnable;
        boolean flag4;
        boolean flag5;
        boolean flag6;
        Runnable runnable1;
        int k1;
        float f;
        float f1;
        float f2;
        float f3;
        float f4;
        float f5;
        if(flag2)
        {
            adropsettingsgroup = new DropSettingsGroup[1];
            adropsettingsgroup[0] = new DropSettingsGroup();
            adropsettingsgroup[0].scrollSpeed = -sharedpreferences.getInt("scrollSpeed", getResources().getInteger(0x7f010000));
            adropsettingsgroup[0].platformHeight = sharedpreferences.getInt("platformHeight", getResources().getInteger(0x7f050006));
            adropsettingsgroup[0].platformHoleWidth = 70;
            adropsettingsgroup[0].yAccel = sharedpreferences.getInt("yAcceleration", getResources().getInteger(0x7f050001));
            adropsettingsgroup[0].yMaxSpeed = sharedpreferences.getInt("yMaxSpeed", getResources().getInteger(0x7f050002));
            adropsettingsgroup[0].yBounce = 0.7F;
            adropsettingsgroup[0].xAccel = sharedpreferences.getInt("xAcceleration", getResources().getInteger(0x7f050003));
            adropsettingsgroup[0].xMaxSpeed = sharedpreferences.getInt("xMaxSpeed", getResources().getInteger(0x7f050004));
            adropsettingsgroup[0].xBounce = sharedpreferences.getFloat("xBounce", 0.5F);
            adropsettingsgroup[0].duration = 20F;
            adropsettingsgroup[0].transitionTiles = false;
        } else
        if(_ControlMode == 0 || _ControlMode == 1)
            adropsettingsgroup = DropSettingsGroup.getTestSettingsA();
        else
            adropsettingsgroup = DropSettingsGroup.getTestSettingsB();
        dropmanager = new DropManager(rectf, adropsettingsgroup);
        _DropManager = dropmanager;
        if(flag)
            _DropManager.init(spriteRenderer, getBaseContext(), k, (float)widthPixels / 320F, (Vibrator)getSystemService("vibrator"));
        else
            _DropManager.init(spriteRenderer, getBaseContext(), k, (float)widthPixels / 320F, null);
        _StatusManager = new StatusManager();
        _StatusManager.init(spriteRenderer, getBaseContext(), (float)widthPixels / 320F, rectf);
        _GameOverLayer = new GameOverLayer();
        _GameOverLayer.init(spriteRenderer, rectf);
        handler = new Handler();
        runnable = new Runnable() {

            public void run()
            {
                handleScore();
            }

            final OpenGLDropActivity this$0;


            {
                this$0 = OpenGLDropActivity.this;
                super();
            }
        }
;
        _DeathDetector = new DeathDetector(rectf, _DropManager, _StatusManager, _GameOverLayer, handler, runnable);
        _DeathDetector.setCurrentHighScore(l);
        if(_ControlMode != 0) goto _L2; else goto _L1
_L1:
        ControlComponent.inAirMovementFactor = 0.3F;
        ControlComponent.inAirMemoryMovementFactor = 0.08F;
        DropManager.speed = 1.0F;
_L4:
        if(flag3)
        {
            k1 = sharedpreferences.getInt("movingAverageValue", 10);
            f = sharedpreferences.getFloat("sensorCutoffX", 5F);
            f1 = sharedpreferences.getFloat("inAirBreak", 0.3F);
            f2 = sharedpreferences.getFloat("inAirMemory", 0.08F);
            f3 = sharedpreferences.getFloat("gameSpeed", 1.0F);
            f4 = sharedpreferences.getFloat("tiltAccelFactor", 1.0F);
            f5 = sharedpreferences.getFloat("tiltAccelDiffFactor", 1.0F);
            MySensorEventListener.SENSOR_CUTOFF_X = f;
            MySensorEventListener.kFilteringFactor = 1.0F / (float)k1;
            MySensorEventListener.accelFactor = f4;
            MySensorEventListener.diffFactor = f5;
            ControlComponent.inAirMovementFactor = 1.0F - f1;
            ControlComponent.inAirMemoryMovementFactor = f2;
            DropManager.speed = f3;
        }
        flag4 = sharedpreferences.getBoolean("canUseDrawTexture", true);
        flag5 = sharedpreferences.getBoolean("canUseVBO", true);
        GLSprite.shouldUseDrawTexture = flag4;
        spriteRenderer.setVertMode(flag5);
        ProfileRecorder.sSingleton.resetAll();
        _StatusManager.setBall(_DropManager.getBall());
        _DropManager.getCollisionComponent().setStatusManager(_StatusManager);
        _ControlComponent = _DropManager.getControlComponent();
        spriteRenderer.endInit();
        simulationRuntime = new MainLoop();
        if(!flag1)
            simulationRuntime.addGameObject(_DeathDetector);
        simulationRuntime.addGameObject(_DropManager);
        simulationRuntime.addGameObject(_StatusManager);
        simulationRuntime.addGameObject(_GameOverLayer);
        setContentView(0x7f030001);
        flag6 = sharedpreferences.getBoolean("glSafeMode", false);
        mGLSurfaceView = (GLSurfaceView)findViewById(0x7f08001f);
        mGLSurfaceView.setRenderer(spriteRenderer);
        mGLSurfaceView.setEvent(simulationRuntime);
        mGLSurfaceView.setSafeMode(flag6);
        runnable1 = new Runnable() {

            public void run()
            {
                android.content.SharedPreferences.Editor editor = getSharedPreferences("DropSettings", 0).edit();
                editor.putString("testError", mGLSurfaceView.getLastError());
                editor.commit();
                Intent intent = new Intent(getApplicationContext(), com/infraredpixel/drop/activities/MainMenuActivity);
                intent.putExtra("justCrashed", true);
                startActivity(intent);
                finish();
            }

            final OpenGLDropActivity this$0;


            {
                this$0 = OpenGLDropActivity.this;
                super();
            }
        }
;
        mGLSurfaceView.setErrorMethod(runnable1);
        sResetFlag = false;
        Runtime.getRuntime().gc();
        return;
_L2:
        if(_ControlMode == 1)
        {
            ControlComponent.inAirMovementFactor = 0.3F;
            ControlComponent.inAirMemoryMovementFactor = 0.08F;
            DropManager.speed = 1.0F;
        } else
        if(_ControlMode == 2)
        {
            mWakeLock = ((PowerManager)getSystemService("power")).newWakeLock(10, "Drop");
            mWakeLock.acquire();
            SensorManager sensormanager = (SensorManager)getSystemService("sensor");
            List list = sensormanager.getSensorList(1);
            int i1 = list.size();
            Sensor sensor = null;
            if(i1 > 0)
                sensor = (Sensor)list.get(0);
            int j1 = getDefaultRotation();
            MySensorEventListener mysensoreventlistener = new MySensorEventListener(_DropManager, _DeathDetector, j1);
            _MyMotionListener = mysensoreventlistener;
            sensormanager.registerListener(_MyMotionListener, sensor, 1);
            MySensorEventListener.SENSOR_CUTOFF_X = 8.3F + 4.5F * (1.0F - sharedpreferences.getFloat("tiltSensitivity", 0.3F));
            MySensorEventListener.kFilteringFactor = 1.0F;
            ControlComponent.inAirMovementFactor = 1.0F;
            ControlComponent.inAirMemoryMovementFactor = 0.0F;
            DropManager.speed = 1.0F;
            MySensorEventListener.accelFactor = 1.0F;
            MySensorEventListener.diffFactor = 2.0F;
        }
        if(true) goto _L4; else goto _L3
_L3:
    }

    public boolean onCreateOptionsMenu(Menu menu)
    {
        if(!TESTING)
        {
            return super.onCreateOptionsMenu(menu);
        } else
        {
            menu.add(0, 1, 0, "profile");
            menu.add(0, 2, 0, "debug/test");
            menu.add(0, 3, 0, "main menu");
            menu.add(0, 4, 0, "pause/resume");
            return true;
        }
    }

    protected void onDestroy()
    {
        if(mWakeLock != null && mWakeLock.isHeld())
        {
            mWakeLock.release();
            mWakeLock = null;
        }
        SensorManager sensormanager = (SensorManager)getSystemService("sensor");
        if(_MyMotionListener != null)
        {
            sensormanager.unregisterListener(_MyMotionListener);
            _MyMotionListener = null;
        }
        mGLSurfaceView = null;
        _DropManager = null;
        _StatusManager = null;
        _DeathDetector = null;
        _GameOverLayer = null;
        simulationRuntime = null;
        _ControlComponent = null;
        super.onDestroy();
    }

    public boolean onKeyDown(int i, KeyEvent keyevent)
    {
        if(_ControlMode == 1)
        {
            if(i == 82 || i == 21)
            {
                _ControlComponent.autoBreak = false;
                _ControlComponent.moveLeft();
                _LeftPressed = true;
                return true;
            }
            if(i == 84 || i == 22)
            {
                _ControlComponent.autoBreak = false;
                _ControlComponent.moveRight();
                _RightPressed = true;
                return true;
            } else
            {
                return super.onKeyDown(i, keyevent);
            }
        } else
        {
            return super.onKeyDown(i, keyevent);
        }
    }

    public boolean onKeyUp(int i, KeyEvent keyevent)
    {
        if(_ControlMode != 1)
            break MISSING_BLOCK_LABEL_102;
        if(i != 82 && i != 21) goto _L2; else goto _L1
_L1:
        boolean flag;
        _LeftPressed = false;
        flag = true;
_L5:
        if(!_LeftPressed && !_RightPressed)
            _ControlComponent.stopMovement();
        if(!_DeathDetector.getDeathOccured())
            _DropManager.start();
        if(flag)
            return true;
        else
            return super.onKeyUp(i, keyevent);
_L2:
        if(i == 84) goto _L4; else goto _L3
_L3:
        flag = false;
        if(i != 22) goto _L5; else goto _L4
_L4:
        _RightPressed = false;
        flag = true;
          goto _L5
        return super.onKeyUp(i, keyevent);
    }

    public boolean onOptionsItemSelected(MenuItem menuitem)
    {
        switch(menuitem.getItemId())
        {
        default:
            return false;

        case 1: // '\001'
            finish();
            startActivity(new Intent(mGLSurfaceView.getContext(), com/infraredpixel/drop/activities/ProfilingActivity));
            return true;

        case 2: // '\002'
            finish();
            startActivity(new Intent(mGLSurfaceView.getContext(), com/infraredpixel/drop/activities/DebugActivity));
            return true;

        case 3: // '\003'
            finish();
            startActivity(new Intent(mGLSurfaceView.getContext(), com/infraredpixel/drop/activities/MainMenuActivity));
            return true;

        case 4: // '\004'
            break;
        }
        if(simulationRuntime.isPaused())
        {
            simulationRuntime.unPause();
            mGLSurfaceView.onResume();
        } else
        {
            simulationRuntime.pause();
            mGLSurfaceView.onPause();
        }
        return true;
    }

    protected void onPause()
    {
        mGLSurfaceView.onPause();
        if(mWakeLock != null && mWakeLock.isHeld())
            mWakeLock.release();
        if(_ControlMode == 2)
        {
            SensorManager sensormanager = (SensorManager)getSystemService("sensor");
            if(_MyMotionListener != null)
                sensormanager.unregisterListener(_MyMotionListener);
        }
        super.onPause();
    }

    protected void onResume()
    {
        mGLSurfaceView.onResume();
        if(sResetFlag)
        {
            handleScore();
            _DropManager.reset();
            sResetFlag = false;
        }
        if(mWakeLock != null && !mWakeLock.isHeld())
            mWakeLock.acquire();
        if(_ControlMode == 2)
        {
            SensorManager sensormanager = (SensorManager)getSystemService("sensor");
            List list = sensormanager.getSensorList(1);
            int i = list.size();
            Sensor sensor = null;
            if(i > 0)
                sensor = (Sensor)list.get(0);
            sensormanager.registerListener(_MyMotionListener, sensor, 1);
        }
        super.onResume();
    }

    protected void onStart()
    {
        super.onStart();
    }

    public boolean onTouchEvent(MotionEvent motionevent)
    {
        if(!_GameOverLayer.isEnabled()) goto _L2; else goto _L1
_L1:
        boolean flag;
        int k = motionevent.getAction();
        flag = false;
        if(k == 0)
        {
            _GameOverLayer.doNextStep();
            flag = true;
        }
_L4:
        int i;
        ControlComponent controlcomponent;
        int j;
        float f;
        try
        {
            Thread.sleep(20L);
        }
        catch(InterruptedException interruptedexception)
        {
            interruptedexception.printStackTrace();
            return flag;
        }
        return flag;
_L2:
        i = _ControlMode;
        flag = false;
        if(i == 0)
        {
            controlcomponent = _ControlComponent;
            flag = false;
            if(controlcomponent != null)
            {
                j = motionevent.getAction();
                f = motionevent.getX();
                if(j == 2)
                {
                    if((float)(widthPixels / 2) < f)
                        _ControlComponent.moveRight();
                    else
                        _ControlComponent.moveLeft();
                    flag = true;
                } else
                if(j == 0)
                {
                    if((float)(widthPixels / 2) < f)
                        _ControlComponent.moveRight();
                    else
                        _ControlComponent.moveLeft();
                    if(!_DeathDetector.getDeathOccured())
                        _DropManager.start();
                    flag = true;
                } else
                {
                    flag = false;
                    if(j == 1)
                    {
                        _ControlComponent.stopMovement();
                        flag = true;
                    }
                }
            }
        }
        if(true) goto _L4; else goto _L3
_L3:
    }

    public boolean onTrackballEvent(MotionEvent motionevent)
    {
        if(_ControlMode == 1)
        {
            if(!_DeathDetector.getDeathOccured())
                _DropManager.start();
            float f = motionevent.getX();
            _ControlComponent.autoBreak = true;
            _ControlComponent.moveSideways(3.5F * f);
            return true;
        } else
        {
            return super.onTrackballEvent(motionevent);
        }
    }

    public static final int CONTROL_MODE_KEYS = 1;
    public static final int CONTROL_MODE_TILT = 2;
    public static final int CONTROL_MODE_TOUCH = 0;
    public static final String PREFS_NAME = "DropSettings";
    private static boolean TESTING = false;
    protected static boolean sResetFlag;
    private ControlComponent _ControlComponent;
    private int _ControlMode;
    DeathDetector _DeathDetector;
    DropManager _DropManager;
    private GameOverLayer _GameOverLayer;
    private boolean _LeftPressed;
    MySensorEventListener _MyMotionListener;
    private boolean _RightPressed;
    StatusManager _StatusManager;
    private GLSurfaceView mGLSurfaceView;
    protected android.os.PowerManager.WakeLock mWakeLock;
    MainLoop simulationRuntime;
    private GLRenderer spriteRenderer;
    private int widthPixels;


}

the program gives many error..

Ravi Kumar
  • 69
  • 9
  • 2
    You are using an inefficient approach. You should not download complex examples from the internet; and then turn to stackoverflow to explain them to you. Instead: start with basic tutorials, follow them step by step. This will allow you to do more complicated things in the course of time. Do not expect that anybody around here is willing to spent his time to do that for you. Your question is too broad; you will mainly receive downvotes; and even if there are answers: they might be beyond your current skill. So, throw away that garbage and start with examples that **you** can understand. – GhostCat Apr 07 '15 at 12:52

2 Answers2

2

What you have here is not real Java, and you should not be using it as an example to learn Java programming from.

So what actually is this stuff?

It looks to me like someone has attempted to decompile an Android app, and the decompiler was unable to turn some of the code back into real Java. Instead, the decompiler has inserted goto "statements" in an attempt to convey the meaning of the code to the (human) reader.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
2

This is obviously the output of a decompilation. While this is a good way to gain specific insight into programs, it's not beginner-level material just like @Jägermeister said, because jads lack the clarity and brevity of standard Java source code.

For example, the goto keyword is not supported on the source code side of the JDK, but it is used inside the byte code in the form of jump instructions. Breaks, continues, loops, ifs etc. may be turned into jumps in surjective ways. The decompiler cannot restore the original construct and resorts to just putting the gotos and labels in the jad. It's up to the programmer to restore reasonable, compilable flow constructs.

That said, the comprehensive answer to your question would be: it's java, but rather an image of the byte code stuff, not a strict restoration of the source code, and requires a manual touch-up to be compilable again.

Community
  • 1
  • 1
hiergiltdiestfu
  • 2,339
  • 2
  • 25
  • 36