├── LICENSE ├── README.md ├── lib ├── attach-1.7.jar ├── cfr_0_139.jar ├── procyon-0.5.33.jar └── weblaf-complete-1.29-fixed.jar ├── pom.xml └── src └── main ├── java ├── android │ └── util │ │ └── Patterns.java ├── me │ ├── grax │ │ └── jbytemod │ │ │ ├── JByteMod.java │ │ │ ├── JarArchive.java │ │ │ ├── analysis │ │ │ ├── block │ │ │ │ └── Block.java │ │ │ ├── converter │ │ │ │ └── Converter.java │ │ │ ├── decompiler │ │ │ │ ├── ClassDefinition.java │ │ │ │ ├── code │ │ │ │ │ ├── TabbedStringBuffer.java │ │ │ │ │ └── ast │ │ │ │ │ │ ├── AstColors.java │ │ │ │ │ │ ├── Comparison.java │ │ │ │ │ │ ├── EndBlock.java │ │ │ │ │ │ ├── Expression.java │ │ │ │ │ │ ├── Operation.java │ │ │ │ │ │ ├── VarType.java │ │ │ │ │ │ └── expressions │ │ │ │ │ │ ├── ArrayIndexExpression.java │ │ │ │ │ │ ├── ArrayStoreExpression.java │ │ │ │ │ │ ├── CastExpression.java │ │ │ │ │ │ ├── ClassTypeExpression.java │ │ │ │ │ │ ├── ComparisonExpression.java │ │ │ │ │ │ ├── DebugStackAssignExpression.java │ │ │ │ │ │ ├── DebugStackExpression.java │ │ │ │ │ │ ├── DebugStackUnknownExpression.java │ │ │ │ │ │ ├── FieldAssignExpression.java │ │ │ │ │ │ ├── FieldExpression.java │ │ │ │ │ │ ├── IncrementExpression.java │ │ │ │ │ │ ├── InstanceofExpression.java │ │ │ │ │ │ ├── InvokeDynamicExpression.java │ │ │ │ │ │ ├── LookupSwitchExpression.java │ │ │ │ │ │ ├── MethodExpression.java │ │ │ │ │ │ ├── NewArrayExpression.java │ │ │ │ │ │ ├── NewPrimArrayExpression.java │ │ │ │ │ │ ├── NewTypeExpression.java │ │ │ │ │ │ ├── NotExpression.java │ │ │ │ │ │ ├── NullExpression.java │ │ │ │ │ │ ├── OpExpression.java │ │ │ │ │ │ ├── ReturnExpression.java │ │ │ │ │ │ ├── SingleOpExpression.java │ │ │ │ │ │ ├── StringExpression.java │ │ │ │ │ │ ├── TableSwitchExpression.java │ │ │ │ │ │ ├── TextExpression.java │ │ │ │ │ │ ├── ThrowExpression.java │ │ │ │ │ │ ├── ValueExpression.java │ │ │ │ │ │ ├── VarAssignExpression.java │ │ │ │ │ │ ├── VarLoadExpression.java │ │ │ │ │ │ └── VarSpecialExpression.java │ │ │ │ ├── defs │ │ │ │ │ └── Keywords.java │ │ │ │ ├── struct │ │ │ │ │ ├── Conversion.java │ │ │ │ │ ├── JVMStack.java │ │ │ │ │ ├── exception │ │ │ │ │ │ ├── StackException.java │ │ │ │ │ │ └── UnknownOPException.java │ │ │ │ │ └── utils │ │ │ │ │ │ └── DescUtils.java │ │ │ │ └── syntax │ │ │ │ │ └── nodes │ │ │ │ │ └── NodeList.java │ │ │ ├── errors │ │ │ │ ├── EmptyMistake.java │ │ │ │ ├── ErrorAnalyzer.java │ │ │ │ ├── InsnError.java │ │ │ │ ├── InsnWarning.java │ │ │ │ └── Mistake.java │ │ │ ├── obfuscation │ │ │ │ ├── ObfuscationAnalyzer.java │ │ │ │ ├── enums │ │ │ │ │ ├── MethodObfType.java │ │ │ │ │ └── NameObfType.java │ │ │ │ └── result │ │ │ │ │ ├── MethodResult.java │ │ │ │ │ └── NamesResult.java │ │ │ └── utils │ │ │ │ └── BlockUtils.java │ │ │ ├── decompiler │ │ │ ├── CFRDecompiler.java │ │ │ ├── Decompiler.java │ │ │ ├── Decompilers.java │ │ │ ├── FernflowerDecompiler.java │ │ │ ├── KrakatauDecompiler.java │ │ │ └── ProcyonDecompiler.java │ │ │ ├── logging │ │ │ └── Logging.java │ │ │ ├── plugin │ │ │ ├── Plugin.java │ │ │ └── PluginManager.java │ │ │ ├── res │ │ │ ├── LanguageRes.java │ │ │ ├── Option.java │ │ │ └── Options.java │ │ │ ├── ui │ │ │ ├── ClassTree.java │ │ │ ├── DecompilerPanel.java │ │ │ ├── DecompilerTab.java │ │ │ ├── InfoPanel.java │ │ │ ├── JAboutFrame.java │ │ │ ├── JAccessHelper.java │ │ │ ├── JAccessSelectorPanel.java │ │ │ ├── JAnnotationEditor.java │ │ │ ├── JFrameList.java │ │ │ ├── JLDCEditor.java │ │ │ ├── JListEditor.java │ │ │ ├── JMethodObfAnalysis.java │ │ │ ├── JNameObfAnalysis.java │ │ │ ├── JObfAnalysis.java │ │ │ ├── JProcessSelection.java │ │ │ ├── JSearch.java │ │ │ ├── MyCodeEditor.java │ │ │ ├── MyEditorTab.java │ │ │ ├── MyMenuBar.java │ │ │ ├── MySplitPane.java │ │ │ ├── MyTabbedPane.java │ │ │ ├── MyToolBar.java │ │ │ ├── NoBorderSP.java │ │ │ ├── OpcodeTable.java │ │ │ ├── PageEndPanel.java │ │ │ ├── TreeCellRenderer.java │ │ │ ├── dialogue │ │ │ │ ├── ClassDialogue.java │ │ │ │ ├── InsnEditDialogue.java │ │ │ │ ├── JChooseString.java │ │ │ │ └── testing │ │ │ │ │ └── TestValues.java │ │ │ ├── graph │ │ │ │ ├── BlockVertex.java │ │ │ │ ├── CFGraph.java │ │ │ │ ├── ControlFlowPanel.java │ │ │ │ ├── PatchedCoordinateAssignment.java │ │ │ │ └── PatchedHierarchicalLayout.java │ │ │ ├── ifs │ │ │ │ ├── CNSettings.java │ │ │ │ ├── LVPFrame.java │ │ │ │ ├── MNSettings.java │ │ │ │ ├── MyInternalFrame.java │ │ │ │ └── TCBFrame.java │ │ │ ├── lists │ │ │ │ ├── AdressList.java │ │ │ │ ├── ErrorList.java │ │ │ │ ├── LVPList.java │ │ │ │ ├── MyCodeList.java │ │ │ │ ├── SearchList.java │ │ │ │ ├── TCBList.java │ │ │ │ └── entries │ │ │ │ │ ├── FieldEntry.java │ │ │ │ │ ├── InstrEntry.java │ │ │ │ │ ├── LVPEntry.java │ │ │ │ │ ├── PrototypeEntry.java │ │ │ │ │ ├── SearchEntry.java │ │ │ │ │ └── TCBEntry.java │ │ │ └── tree │ │ │ │ └── SortedTreeNode.java │ │ │ └── utils │ │ │ ├── ErrorDisplay.java │ │ │ ├── FileUtils.java │ │ │ ├── HtmlSelection.java │ │ │ ├── ImageUtils.java │ │ │ ├── InstrUtils.java │ │ │ ├── MethodUtils.java │ │ │ ├── TextUtils.java │ │ │ ├── ThemeChanges.java │ │ │ ├── asm │ │ │ ├── FrameGen.java │ │ │ ├── Hints.java │ │ │ ├── LibClassWriter.java │ │ │ ├── Loader.java │ │ │ └── ParentUtils.java │ │ │ ├── attach │ │ │ ├── AttachUtils.java │ │ │ ├── InjectUtils.java │ │ │ └── RuntimeJarArchive.java │ │ │ ├── gui │ │ │ ├── LookUtils.java │ │ │ └── SwingUtils.java │ │ │ ├── list │ │ │ └── LazyListModel.java │ │ │ └── task │ │ │ ├── AttachTask.java │ │ │ ├── LoadTask.java │ │ │ ├── RetransformTask.java │ │ │ ├── SaveTask.java │ │ │ └── search │ │ │ ├── LdcTask.java │ │ │ ├── ReferenceTask.java │ │ │ └── SFTask.java │ └── lpk │ │ └── util │ │ ├── ASMUtils.java │ │ ├── AccessHelper.java │ │ ├── JarUtils.java │ │ ├── OpUtils.java │ │ ├── StringUtils.java │ │ └── drop │ │ ├── IDropUser.java │ │ └── JarDropHandler.java └── org │ ├── jetbrains │ └── java │ │ └── decompiler │ │ ├── code │ │ ├── CodeConstants.java │ │ ├── ConstantsUtil.java │ │ ├── ExceptionHandler.java │ │ ├── ExceptionTable.java │ │ ├── FullInstructionSequence.java │ │ ├── IfInstruction.java │ │ ├── Instruction.java │ │ ├── InstructionSequence.java │ │ ├── JumpInstruction.java │ │ ├── SimpleInstructionSequence.java │ │ ├── SwitchInstruction.java │ │ ├── cfg │ │ │ ├── BasicBlock.java │ │ │ ├── ControlFlowGraph.java │ │ │ └── ExceptionRangeCFG.java │ │ ├── interpreter │ │ │ ├── InstructionImpact.java │ │ │ └── Util.java │ │ └── optinstructions │ │ │ ├── ALOAD.java │ │ │ ├── ANEWARRAY.java │ │ │ ├── ASTORE.java │ │ │ ├── BIPUSH.java │ │ │ ├── CHECKCAST.java │ │ │ ├── DLOAD.java │ │ │ ├── DSTORE.java │ │ │ ├── FLOAD.java │ │ │ ├── FSTORE.java │ │ │ ├── GETFIELD.java │ │ │ ├── GETSTATIC.java │ │ │ ├── GOTO.java │ │ │ ├── GOTO_W.java │ │ │ ├── IINC.java │ │ │ ├── ILOAD.java │ │ │ ├── INSTANCEOF.java │ │ │ ├── INVOKEDYNAMIC.java │ │ │ ├── INVOKEINTERFACE.java │ │ │ ├── INVOKESPECIAL.java │ │ │ ├── INVOKESTATIC.java │ │ │ ├── INVOKEVIRTUAL.java │ │ │ ├── ISTORE.java │ │ │ ├── JSR.java │ │ │ ├── JSR_W.java │ │ │ ├── LDC.java │ │ │ ├── LDC2_W.java │ │ │ ├── LDC_W.java │ │ │ ├── LLOAD.java │ │ │ ├── LOOKUPSWITCH.java │ │ │ ├── LSTORE.java │ │ │ ├── MULTIANEWARRAY.java │ │ │ ├── NEW.java │ │ │ ├── NEWARRAY.java │ │ │ ├── PUTFIELD.java │ │ │ ├── PUTSTATIC.java │ │ │ ├── RET.java │ │ │ ├── SIPUSH.java │ │ │ └── TABLESWITCH.java │ │ ├── main │ │ ├── AssertProcessor.java │ │ ├── ClassReference14Processor.java │ │ ├── ClassWriter.java │ │ ├── ClassesProcessor.java │ │ ├── DecompilerContext.java │ │ ├── EnumProcessor.java │ │ ├── Fernflower.java │ │ ├── InitializerProcessor.java │ │ ├── TextBuffer.java │ │ ├── collectors │ │ │ ├── BytecodeMappingTracer.java │ │ │ ├── BytecodeSourceMapper.java │ │ │ ├── CounterContainer.java │ │ │ ├── ImportCollector.java │ │ │ └── VarNamesCollector.java │ │ ├── decompiler │ │ │ ├── BaseDecompiler.java │ │ │ ├── ConsoleDecompiler.java │ │ │ └── PrintStreamLogger.java │ │ ├── extern │ │ │ ├── IBytecodeProvider.java │ │ │ ├── IFernflowerLogger.java │ │ │ ├── IFernflowerPreferences.java │ │ │ ├── IIdentifierRenamer.java │ │ │ └── IResultSaver.java │ │ └── rels │ │ │ ├── ClassWrapper.java │ │ │ ├── LambdaProcessor.java │ │ │ ├── MethodProcessorRunnable.java │ │ │ ├── MethodWrapper.java │ │ │ ├── NestedClassProcessor.java │ │ │ └── NestedMemberAccess.java │ │ ├── modules │ │ ├── code │ │ │ └── DeadCodeHelper.java │ │ ├── decompiler │ │ │ ├── ClearStructHelper.java │ │ │ ├── ConcatenationHelper.java │ │ │ ├── DecHelper.java │ │ │ ├── DomHelper.java │ │ │ ├── EliminateLoopsHelper.java │ │ │ ├── ExitHelper.java │ │ │ ├── ExprProcessor.java │ │ │ ├── ExprentStack.java │ │ │ ├── FinallyProcessor.java │ │ │ ├── IdeaNotNullHelper.java │ │ │ ├── IfHelper.java │ │ │ ├── InlineSingleBlockHelper.java │ │ │ ├── LabelHelper.java │ │ │ ├── LoopExtractHelper.java │ │ │ ├── LowBreakHelper.java │ │ │ ├── MergeHelper.java │ │ │ ├── PPandMMHelper.java │ │ │ ├── PrimitiveExprsList.java │ │ │ ├── SecondaryFunctionsHelper.java │ │ │ ├── SequenceHelper.java │ │ │ ├── SimplifyExprentsHelper.java │ │ │ ├── StackVarsProcessor.java │ │ │ ├── StatEdge.java │ │ │ ├── StrongConnectivityHelper.java │ │ │ ├── decompose │ │ │ │ ├── DominatorEngine.java │ │ │ │ ├── DominatorTreeExceptionFilter.java │ │ │ │ ├── FastExtendedPostdominanceHelper.java │ │ │ │ ├── GenericDominatorEngine.java │ │ │ │ ├── IGraph.java │ │ │ │ └── IGraphNode.java │ │ │ ├── deobfuscator │ │ │ │ ├── ExceptionDeobfuscator.java │ │ │ │ └── IrreducibleCFGDeobfuscator.java │ │ │ ├── exps │ │ │ │ ├── AnnotationExprent.java │ │ │ │ ├── ArrayExprent.java │ │ │ │ ├── AssertExprent.java │ │ │ │ ├── AssignmentExprent.java │ │ │ │ ├── ConstExprent.java │ │ │ │ ├── ExitExprent.java │ │ │ │ ├── Exprent.java │ │ │ │ ├── FieldExprent.java │ │ │ │ ├── FunctionExprent.java │ │ │ │ ├── IfExprent.java │ │ │ │ ├── InvocationExprent.java │ │ │ │ ├── MonitorExprent.java │ │ │ │ ├── NewExprent.java │ │ │ │ ├── SwitchExprent.java │ │ │ │ ├── TypeAnnotation.java │ │ │ │ └── VarExprent.java │ │ │ ├── sforms │ │ │ │ ├── DirectGraph.java │ │ │ │ ├── DirectNode.java │ │ │ │ ├── FlattenStatementsHelper.java │ │ │ │ ├── SSAConstructorSparseEx.java │ │ │ │ └── SSAUConstructorSparseEx.java │ │ │ ├── stats │ │ │ │ ├── BasicBlockStatement.java │ │ │ │ ├── CatchAllStatement.java │ │ │ │ ├── CatchStatement.java │ │ │ │ ├── DoStatement.java │ │ │ │ ├── DummyExitStatement.java │ │ │ │ ├── GeneralStatement.java │ │ │ │ ├── IfStatement.java │ │ │ │ ├── RootStatement.java │ │ │ │ ├── SequenceStatement.java │ │ │ │ ├── Statement.java │ │ │ │ ├── Statements.java │ │ │ │ ├── SwitchStatement.java │ │ │ │ └── SynchronizedStatement.java │ │ │ └── vars │ │ │ │ ├── CheckTypesResult.java │ │ │ │ ├── VarDefinitionHelper.java │ │ │ │ ├── VarProcessor.java │ │ │ │ ├── VarTypeProcessor.java │ │ │ │ ├── VarVersionEdge.java │ │ │ │ ├── VarVersionNode.java │ │ │ │ ├── VarVersionPair.java │ │ │ │ ├── VarVersionsGraph.java │ │ │ │ └── VarVersionsProcessor.java │ │ └── renamer │ │ │ ├── ClassWrapperNode.java │ │ │ ├── ConverterHelper.java │ │ │ ├── IdentifierConverter.java │ │ │ └── PoolInterceptor.java │ │ ├── struct │ │ ├── ContextUnit.java │ │ ├── IDecompiledData.java │ │ ├── StructClass.java │ │ ├── StructContext.java │ │ ├── StructField.java │ │ ├── StructMember.java │ │ ├── StructMethod.java │ │ ├── attr │ │ │ ├── StructAnnDefaultAttribute.java │ │ │ ├── StructAnnotationAttribute.java │ │ │ ├── StructAnnotationParameterAttribute.java │ │ │ ├── StructBootstrapMethodsAttribute.java │ │ │ ├── StructConstantValueAttribute.java │ │ │ ├── StructEnclosingMethodAttribute.java │ │ │ ├── StructExceptionsAttribute.java │ │ │ ├── StructGeneralAttribute.java │ │ │ ├── StructGenericSignatureAttribute.java │ │ │ ├── StructInnerClassesAttribute.java │ │ │ ├── StructLineNumberTableAttribute.java │ │ │ ├── StructLocalVariableTableAttribute.java │ │ │ ├── StructSourceFileAttribute.java │ │ │ └── StructTypeAnnotationAttribute.java │ │ ├── consts │ │ │ ├── ConstantPool.java │ │ │ ├── LinkConstant.java │ │ │ ├── PooledConstant.java │ │ │ ├── PrimitiveConstant.java │ │ │ └── VariableTypeEnum.java │ │ ├── gen │ │ │ ├── DataPoint.java │ │ │ ├── FieldDescriptor.java │ │ │ ├── MethodDescriptor.java │ │ │ ├── NewClassNameBuilder.java │ │ │ ├── VarType.java │ │ │ └── generics │ │ │ │ ├── GenericClassDescriptor.java │ │ │ │ ├── GenericFieldDescriptor.java │ │ │ │ ├── GenericMain.java │ │ │ │ ├── GenericMethodDescriptor.java │ │ │ │ └── GenericType.java │ │ ├── lazy │ │ │ └── LazyLoader.java │ │ └── match │ │ │ ├── IMatchable.java │ │ │ ├── MatchEngine.java │ │ │ └── MatchNode.java │ │ └── util │ │ ├── DataInputFullStream.java │ │ ├── FastFixedSetFactory.java │ │ ├── FastSetFactory.java │ │ ├── FastSparseSetFactory.java │ │ ├── InterpreterUtil.java │ │ ├── ListStack.java │ │ ├── SFormsFastMapDirect.java │ │ ├── TextUtil.java │ │ └── VBStyleCollection.java │ └── objectweb │ └── asm │ ├── AnnotationVisitor.java │ ├── AnnotationWriter.java │ ├── Attribute.java │ ├── ByteVector.java │ ├── ClassReader.java │ ├── ClassVisitor.java │ ├── ClassWriter.java │ ├── ConstantDynamic.java │ ├── Constants.java │ ├── Context.java │ ├── CurrentFrame.java │ ├── Edge.java │ ├── FieldVisitor.java │ ├── FieldWriter.java │ ├── Frame.java │ ├── Handle.java │ ├── Handler.java │ ├── Label.java │ ├── MethodVisitor.java │ ├── MethodWriter.java │ ├── ModuleVisitor.java │ ├── ModuleWriter.java │ ├── Opcodes.java │ ├── Symbol.java │ ├── SymbolTable.java │ ├── Type.java │ ├── TypePath.java │ ├── TypeReference.java │ ├── commons │ ├── AdviceAdapter.java │ ├── AnalyzerAdapter.java │ ├── AnnotationRemapper.java │ ├── ClassRemapper.java │ ├── CodeSizeEvaluator.java │ ├── FieldRemapper.java │ ├── GeneratorAdapter.java │ ├── InstructionAdapter.java │ ├── JSRInlinerAdapter.java │ ├── LocalVariablesSorter.java │ ├── Method.java │ ├── MethodRemapper.java │ ├── ModuleHashesAttribute.java │ ├── ModuleRemapper.java │ ├── ModuleResolutionAttribute.java │ ├── ModuleTargetAttribute.java │ ├── Remapper.java │ ├── RemappingAnnotationAdapter.java │ ├── RemappingClassAdapter.java │ ├── RemappingFieldAdapter.java │ ├── RemappingMethodAdapter.java │ ├── RemappingSignatureAdapter.java │ ├── SerialVersionUIDAdder.java │ ├── SignatureRemapper.java │ ├── SimpleRemapper.java │ ├── StaticInitMerger.java │ ├── TableSwitchGenerator.java │ ├── TryCatchBlockSorter.java │ └── package.html │ ├── optimizer │ ├── AnnotationConstantsCollector.java │ ├── ClassConstantsCollector.java │ ├── ClassOptimizer.java │ ├── Constant.java │ ├── ConstantPool.java │ ├── FieldConstantsCollector.java │ ├── JarOptimizer.java │ ├── MethodConstantsCollector.java │ ├── MethodOptimizer.java │ ├── NameMapping.java │ └── Shrinker.java │ ├── package.html │ ├── signature │ ├── SignatureReader.java │ ├── SignatureVisitor.java │ ├── SignatureWriter.java │ └── package.html │ ├── tree │ ├── AbstractInsnNode.java │ ├── AnnotationNode.java │ ├── ClassNode.java │ ├── FieldInsnNode.java │ ├── FieldNode.java │ ├── FrameNode.java │ ├── IincInsnNode.java │ ├── InnerClassNode.java │ ├── InsnList.java │ ├── InsnNode.java │ ├── IntInsnNode.java │ ├── InvokeDynamicInsnNode.java │ ├── JumpInsnNode.java │ ├── LabelNode.java │ ├── LdcInsnNode.java │ ├── LineNumberNode.java │ ├── LocalVariableAnnotationNode.java │ ├── LocalVariableNode.java │ ├── LookupSwitchInsnNode.java │ ├── MethodInsnNode.java │ ├── MethodNode.java │ ├── ModuleExportNode.java │ ├── ModuleNode.java │ ├── ModuleOpenNode.java │ ├── ModuleProvideNode.java │ ├── ModuleRequireNode.java │ ├── MultiANewArrayInsnNode.java │ ├── ParameterNode.java │ ├── TableSwitchInsnNode.java │ ├── TryCatchBlockNode.java │ ├── TypeAnnotationNode.java │ ├── TypeInsnNode.java │ ├── VarInsnNode.java │ ├── analysis │ │ ├── Analyzer.java │ │ ├── AnalyzerException.java │ │ ├── BasicInterpreter.java │ │ ├── BasicValue.java │ │ ├── BasicVerifier.java │ │ ├── Frame.java │ │ ├── Interpreter.java │ │ ├── SimpleVerifier.java │ │ ├── SmallSet.java │ │ ├── SourceInterpreter.java │ │ ├── SourceValue.java │ │ ├── Subroutine.java │ │ ├── Value.java │ │ └── package.html │ └── package.html │ ├── util │ ├── ASMifiable.java │ ├── ASMifier.java │ ├── CheckAnnotationAdapter.java │ ├── CheckClassAdapter.java │ ├── CheckFieldAdapter.java │ ├── CheckMethodAdapter.java │ ├── CheckModuleAdapter.java │ ├── CheckSignatureAdapter.java │ ├── Printer.java │ ├── Textifiable.java │ ├── Textifier.java │ ├── TraceAnnotationVisitor.java │ ├── TraceClassVisitor.java │ ├── TraceFieldVisitor.java │ ├── TraceMethodVisitor.java │ ├── TraceModuleVisitor.java │ ├── TraceSignatureVisitor.java │ └── package.html │ └── xml │ ├── ASMContentHandler.java │ ├── Processor.java │ ├── SAXAdapter.java │ ├── SAXAnnotationAdapter.java │ ├── SAXClassAdapter.java │ ├── SAXCodeAdapter.java │ ├── SAXFieldAdapter.java │ ├── SAXModuleAdapter.java │ ├── asm-xml.dtd │ └── package.html └── resources ├── locale ├── de.xml ├── en.xml ├── es.xml ├── pt-br.xml ├── ru.xml ├── zh-cn.xml ├── zh-tr.xml └── zh.xml └── resources ├── LICENSES ├── access ├── abstract.png ├── final.png ├── native.png ├── static.png └── synthetic.png ├── classtype ├── enum.png └── interface.png ├── file.png ├── html └── optable.html ├── icon_close.png ├── jar.png ├── java.png ├── krakatau.zip ├── method ├── methdef.png ├── methpri.png ├── methpro.png └── methpub.png ├── package.png ├── search.png ├── toolbar ├── load.png ├── plug.png ├── refresh.png ├── save.png ├── search.png └── table.png ├── txt.png └── warning.png /README.md: -------------------------------------------------------------------------------- 1 | # JByteMod-Beta 2 | JByteMod is a multifunctional bytecode editor with syntax highlighting and live decompiling and method graphing. 3 | The successor of JByteMod: https://github.com/GraxCode/Cafebabe 4 | 5 | ![Screenshot 1](https://i.imgur.com/9RUqMYC.png) 6 | ![Screenshot 2](https://i.imgur.com/Cjj1Dh0.png) 7 | ![Screenshot 3](https://i.imgur.com/0x21dMo.png) 8 | ![Screenshot 4](https://i.imgur.com/NdWIxqd.png) 9 | ![Screenshot 5](https://i.imgur.com/eSUKCHi.png) 10 | 11 | JByteMod was originally based on JBytedit (Written in Kotlin) by QMatt. 12 | I decided to recode it after QMatt deleted his account because it wasn't very stable and had almost no features. 13 | 14 | ## CLI 15 | | Argument | Description | 16 | | --- | --- | 17 | | --help | Displays help | 18 | | --file | File to open (.jar / .class) | 19 | | --dir | Working directory | 20 | | --config | Config file name | 21 | 22 | 23 | ## Libraries 24 | - Apache Commons IO 25 | - Objectweb ASM 26 | - RSyntaxTextArea 27 | - SkidSuite 28 | - Procyon Decompiler 29 | - Fernflower Decompiler 30 | - JGraphX 31 | - JFreeGraph 32 | 33 | ## Plugins 34 | 35 | To create a plugin you have to extend me.grax.jbytemod.Plugin and export it as a .jar file. 36 | 37 | ### Installation 38 | 39 | To install a plugin you have to place the .jar file in a folder named "plugins" (that's in the same directory as JByteMod) 40 | 41 | ### Example Plugin 42 | 43 | https://github.com/GraxCode/JTattooPlugin 44 | 45 | ## How to build 46 | 47 | mvn clean 48 | mvn package 49 | java -jar target/JByteMod-1.5.1.jar 50 | 51 | -------------------------------------------------------------------------------- /lib/attach-1.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/lib/attach-1.7.jar -------------------------------------------------------------------------------- /lib/cfr_0_139.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/lib/cfr_0_139.jar -------------------------------------------------------------------------------- /lib/procyon-0.5.33.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/lib/procyon-0.5.33.jar -------------------------------------------------------------------------------- /lib/weblaf-complete-1.29-fixed.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/lib/weblaf-complete-1.29-fixed.jar -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/JarArchive.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod; 2 | 3 | import java.io.File; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import me.grax.jbytemod.utils.ErrorDisplay; 10 | import me.grax.jbytemod.utils.task.LoadTask; 11 | 12 | public class JarArchive { 13 | protected Map classes; 14 | protected Map output; 15 | private boolean singleEntry; 16 | 17 | public JarArchive(ClassNode cn) { 18 | super(); 19 | this.classes = new HashMap<>(); 20 | this.singleEntry = true; 21 | classes.put(cn.name, cn); 22 | } 23 | 24 | public JarArchive(JByteMod jbm, File input) { 25 | try { 26 | new LoadTask(jbm, input, this).execute(); 27 | } catch (Throwable t) { 28 | new ErrorDisplay(t); 29 | } 30 | } 31 | 32 | public JarArchive(Map classes, Map output) { 33 | super(); 34 | this.classes = classes; 35 | this.output = output; 36 | } 37 | 38 | public Map getClasses() { 39 | return classes; 40 | } 41 | 42 | public Map getOutput() { 43 | return output; 44 | } 45 | 46 | public boolean isSingleEntry() { 47 | return singleEntry; 48 | } 49 | 50 | public void setClasses(Map classes) { 51 | this.classes = classes; 52 | } 53 | 54 | public void setOutput(Map output) { 55 | this.output = output; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/ClassDefinition.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler; 2 | 3 | public class ClassDefinition { 4 | private String name; 5 | 6 | public ClassDefinition(String name) { 7 | super(); 8 | if (name.startsWith("L") && name.endsWith(";")) { 9 | this.name = name.substring(1, name.length() - 1); 10 | } else { 11 | this.name = name; 12 | } 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getShortName() { 24 | if (!name.contains("/")) { 25 | return name; 26 | } 27 | return name.substring(name.lastIndexOf("/") + 1); 28 | } 29 | 30 | public String getSourceName() { 31 | return name.replace('/', '.'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/TabbedStringBuffer.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code; 2 | 3 | public class TabbedStringBuffer { 4 | public int tabs; 5 | private StringBuilder sb = new StringBuilder(); 6 | 7 | public void append(String s) { 8 | sb.append(s); 9 | } 10 | 11 | public void indent() { 12 | for (int i = 0; i < tabs; i++) { 13 | sb.append(" "); 14 | } 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return sb.toString(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/AstColors.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public class AstColors { 4 | public static final String edgeColor = "#111111"; 5 | public static final String jumpColor = "#39698a"; 6 | 7 | public static final String jumpColorGreen = "#388a47"; 8 | public static final String jumpColorRed = "#8a3e38"; 9 | public static final String jumpColorPurple = "#71388a"; 10 | public static final String jumpColorPink = "#ba057a"; //8a386d 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/Comparison.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public enum Comparison { 4 | IS("=="), ISNOT("!="), LOWER("<"), LOWEREQUALS("<="), GREATER(">"), GREATEREQUALS(">="); 5 | 6 | private String symbol; 7 | 8 | private Comparison(String symbol) { 9 | this.symbol = symbol; 10 | } 11 | 12 | public String getSymbol() { 13 | return symbol; 14 | } 15 | 16 | public void setSymbol(String symbol) { 17 | this.symbol = symbol; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/EndBlock.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public enum EndBlock { 4 | CONTINUE, BREAK; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/Expression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public abstract class Expression { 4 | public abstract String toString(); 5 | 6 | public abstract int size(); 7 | 8 | public abstract Expression clone(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/Operation.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | import org.objectweb.asm.Opcodes; 4 | 5 | public enum Operation implements Opcodes { 6 | ADD("+"), SUB("-"), MUL("*"), DIV("/"), REM("%"), SHL("<<"), SHR(">>"), USHR(">>>"), AND("&"), OR("|"), XOR("^"), NEG("-"); 7 | 8 | private String symbol; 9 | 10 | Operation(String symbol) { 11 | this.symbol = symbol; 12 | } 13 | 14 | public String getSymbol() { 15 | return symbol; 16 | } 17 | 18 | public void setSymbol(String symbol) { 19 | this.symbol = symbol; 20 | } 21 | 22 | public static Operation of(int opc) { 23 | switch (opc) { 24 | case IADD: 25 | case DADD: 26 | case FADD: 27 | case LADD: 28 | return Operation.ADD; 29 | case ISUB: 30 | case FSUB: 31 | case LSUB: 32 | case DSUB: 33 | return Operation.SUB; 34 | case IMUL: 35 | case FMUL: 36 | case LMUL: 37 | case DMUL: 38 | return Operation.MUL; 39 | case IDIV: 40 | case FDIV: 41 | case LDIV: 42 | case DDIV: 43 | return Operation.DIV; 44 | case IREM: 45 | case FREM: 46 | case LREM: 47 | case DREM: 48 | return Operation.REM; 49 | case ISHL: 50 | case LSHL: 51 | return Operation.SHL; 52 | case ISHR: 53 | case LSHR: 54 | return Operation.SHR; 55 | case IUSHR: 56 | case LUSHR: 57 | return Operation.USHR; 58 | case IAND: 59 | case LAND: 60 | return Operation.AND; 61 | case IOR: 62 | case LOR: 63 | return Operation.OR; 64 | case IXOR: 65 | case LXOR: 66 | return Operation.XOR; 67 | case INEG: 68 | case FNEG: 69 | case LNEG: 70 | case DNEG: 71 | return Operation.NEG; 72 | } 73 | throw new RuntimeException("unresolved operation"); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/VarType.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public enum VarType { 4 | INT("int"), FLOAT("float"), LONG("long"), DOUBLE("double"), OBJECT("Object"), VOID("void"), BOOLEAN("boolean"), CHAR("char"), BYTE("byte"), SHORT( 5 | "short"); 6 | private String type; 7 | 8 | VarType(String type) { 9 | this.type = type; 10 | } 11 | 12 | public String getType() { 13 | return type; 14 | } 15 | 16 | public void setType(String type) { 17 | this.type = type; 18 | } 19 | 20 | public int size() { 21 | return (this == VarType.LONG || this == VarType.DOUBLE) ? 2 : 1; 22 | } 23 | 24 | public static VarType ofDesc(String desc) { 25 | if (desc.contains(")")) { 26 | desc = desc.substring(desc.lastIndexOf(')') + 1); 27 | } 28 | if (desc.endsWith(";") || desc.contains("[")) 29 | return OBJECT; 30 | if (desc.endsWith("V")) 31 | return VOID; 32 | if (desc.endsWith("F")) 33 | return FLOAT; 34 | if (desc.endsWith("J")) 35 | return LONG; 36 | if (desc.endsWith("D")) 37 | return DOUBLE; 38 | if (desc.endsWith("Z")) 39 | return BOOLEAN; 40 | if (desc.endsWith("C")) 41 | return CHAR; 42 | if (desc.endsWith("B")) 43 | return BYTE; 44 | if (desc.endsWith("S")) 45 | return SHORT; 46 | return INT; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ArrayIndexExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.InstrUtils; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class ArrayIndexExpression extends Expression { 8 | 9 | private Expression array; 10 | private Expression index; 11 | private boolean twoword; 12 | 13 | public ArrayIndexExpression(Expression array, Expression index, boolean twoword) { 14 | super(); 15 | this.array = array; 16 | this.index = index; 17 | this.twoword = twoword; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return TextUtils.addTag(array.toString(), "font color=" + InstrUtils.primColor.getString()) + "[" + index + "]"; 23 | } 24 | 25 | @Override 26 | public int size() { 27 | return twoword ? 2 : 1; 28 | } 29 | 30 | @Override 31 | public Expression clone() { 32 | return new ArrayIndexExpression(array.clone(), index.clone(), twoword); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ArrayStoreExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.InstrUtils; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class ArrayStoreExpression extends Expression { 8 | private Expression array; 9 | private Expression index; 10 | private Expression value; 11 | 12 | public ArrayStoreExpression(Expression array, Expression index, Expression value) { 13 | super(); 14 | this.array = array; 15 | this.index = index; 16 | this.value = value; 17 | 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return TextUtils.addTag(array.toString(), "font color=" + InstrUtils.primColor.getString()) + "[" + index + "]" + " = " + value; 23 | } 24 | 25 | @Override 26 | public int size() { 27 | return 0; 28 | } 29 | 30 | @Override 31 | public Expression clone() { 32 | return new ArrayStoreExpression(array.clone(), index.clone(), value.clone()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ClassTypeExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class ClassTypeExpression extends Expression { 6 | 7 | private String object; 8 | 9 | public ClassTypeExpression(String object) { 10 | this.object = object; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | return object + ".class"; 16 | } 17 | 18 | @Override 19 | public int size() { 20 | return 1; 21 | } 22 | 23 | @Override 24 | public Expression clone() { 25 | return new ClassTypeExpression(object); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ComparisonExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Comparison; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class ComparisonExpression extends Expression { 8 | 9 | private Expression left; 10 | private Comparison comparison; 11 | private Expression right; 12 | 13 | public ComparisonExpression(Expression left, Comparison comparison, Expression right) { 14 | super(); 15 | this.left = left; 16 | this.comparison = comparison; 17 | this.right = right; 18 | } 19 | 20 | public Expression getLeft() { 21 | return left; 22 | } 23 | 24 | public void setLeft(Expression left) { 25 | this.left = left; 26 | } 27 | 28 | public Comparison getComparison() { 29 | return comparison; 30 | } 31 | 32 | public void setComparison(Comparison comparison) { 33 | this.comparison = comparison; 34 | } 35 | 36 | public Expression getRight() { 37 | return right; 38 | } 39 | 40 | public void setRight(Expression right) { 41 | this.right = right; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "if " + left.toString() + " " + TextUtils.escape(comparison.getSymbol()) + " " + right.toString() + ""; 47 | } 48 | 49 | @Override 50 | public int size() { 51 | return 1; 52 | } 53 | 54 | @Override 55 | public Expression clone() { 56 | return new ComparisonExpression(left.clone(), comparison, right.clone()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/DebugStackAssignExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class DebugStackAssignExpression extends Expression { 7 | 8 | private int var; 9 | private Expression value; 10 | private String prefix; 11 | 12 | public DebugStackAssignExpression(int var, Expression value) { 13 | this(var, value, "stack"); 14 | } 15 | 16 | public DebugStackAssignExpression(int var, Expression value, String prefix) { 17 | this.var = var; 18 | this.value = value; 19 | this.prefix = prefix; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return TextUtils.addTag("" + prefix + var + "", "font color=#909011") + " = " + value; 25 | } 26 | 27 | @Override 28 | public int size() { 29 | return 0; 30 | } 31 | 32 | public String getPrefix() { 33 | return prefix; 34 | } 35 | 36 | public void setPrefix(String prefix) { 37 | this.prefix = prefix; 38 | } 39 | 40 | @Override 41 | public Expression clone() { 42 | return new DebugStackAssignExpression(var, value.clone(), prefix); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/DebugStackExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class DebugStackExpression extends Expression { 8 | 9 | private int var; 10 | private int size; 11 | private VarType type; 12 | private String prefix; 13 | 14 | public DebugStackExpression(int var, int size, VarType type) { 15 | this(var, size, type, "stack"); 16 | } 17 | 18 | public DebugStackExpression(int var, int size, VarType type, String prefix) { 19 | this.var = var; 20 | this.size = size; 21 | this.type = type; 22 | this.prefix = prefix; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return TextUtils.addTag("" + prefix + var + "", "font color=#909011"); 28 | } 29 | 30 | @Override 31 | public int size() { 32 | return size; 33 | } 34 | 35 | @Override 36 | public Expression clone() { 37 | return new DebugStackExpression(var, size, type, prefix); 38 | } 39 | 40 | public int getVar() { 41 | return var; 42 | } 43 | 44 | public void setVar(int var) { 45 | this.var = var; 46 | } 47 | 48 | public int getSize() { 49 | return size; 50 | } 51 | 52 | public void setSize(int size) { 53 | this.size = size; 54 | } 55 | 56 | public VarType getType() { 57 | return type; 58 | } 59 | 60 | public void setType(VarType type) { 61 | this.type = type; 62 | } 63 | 64 | public String getPrefix() { 65 | return prefix; 66 | } 67 | 68 | public void setPrefix(String prefix) { 69 | this.prefix = prefix; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/DebugStackUnknownExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class DebugStackUnknownExpression extends Expression { 8 | 9 | private int var; 10 | private int size; 11 | private VarType type; 12 | 13 | public DebugStackUnknownExpression(int var, int size, VarType type) { 14 | this.var = var; 15 | this.size = size; 16 | this.type = type; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return TextUtils.addTag("unkn_stack_" + var + "", "font color=#997755"); 22 | } 23 | 24 | @Override 25 | public int size() { 26 | return size; 27 | } 28 | 29 | @Override 30 | public Expression clone() { 31 | return new DebugStackUnknownExpression(var, size, type); 32 | } 33 | 34 | public int getVar() { 35 | return var; 36 | } 37 | 38 | public void setVar(int var) { 39 | this.var = var; 40 | } 41 | 42 | public int getSize() { 43 | return size; 44 | } 45 | 46 | public void setSize(int size) { 47 | this.size = size; 48 | } 49 | 50 | public VarType getType() { 51 | return type; 52 | } 53 | 54 | public void setType(VarType type) { 55 | this.type = type; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/IncrementExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.InstrUtils; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class IncrementExpression extends Expression { 8 | private Expression object; 9 | private int increment; 10 | 11 | public IncrementExpression(Expression object, int increment) { 12 | super(); 13 | this.object = object; 14 | this.increment = increment; 15 | } 16 | 17 | public Expression getObject() { 18 | return object; 19 | } 20 | 21 | public void setObject(Expression object) { 22 | this.object = object; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return TextUtils.addTag(object.toString(), "font color=" + InstrUtils.primColor.getString()) + " += " + increment; 28 | } 29 | 30 | @Override 31 | public int size() { 32 | return 0; 33 | } 34 | 35 | @Override 36 | public Expression clone() { 37 | return new IncrementExpression(object.clone(), increment); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/InstanceofExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.ClassDefinition; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 5 | 6 | public class InstanceofExpression extends Expression { 7 | 8 | private Expression object; 9 | private ClassDefinition classDef; 10 | 11 | public InstanceofExpression(Expression object, ClassDefinition classDef) { 12 | super(); 13 | this.object = object; 14 | this.classDef = classDef; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return object.toString() + " instanceof " + classDef.getName(); 20 | } 21 | 22 | @Override 23 | public int size() { 24 | return 1; 25 | } 26 | 27 | @Override 28 | public Expression clone() { 29 | return new InstanceofExpression(object.clone(), classDef); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/LookupSwitchExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class LookupSwitchExpression extends Expression { 6 | 7 | private Expression toSwitch; 8 | private int size; 9 | 10 | public LookupSwitchExpression(Expression toSwitch, int size) { 11 | this.toSwitch = toSwitch; 12 | this.size = size; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "switch(" + toSwitch + ") " + size + " cases"; 18 | } 19 | 20 | @Override 21 | public int size() { 22 | return 1; 23 | } 24 | 25 | @Override 26 | public Expression clone() { 27 | return new LookupSwitchExpression(toSwitch.clone(), size); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NewArrayExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.ClassDefinition; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class NewArrayExpression extends Expression { 9 | private Expression count; 10 | private ClassDefinition object; 11 | 12 | public NewArrayExpression(Expression count, ClassDefinition object) { 13 | super(); 14 | this.count = count; 15 | this.object = object; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "new " + TextUtils.addTag(object.getName(), "font color=" + InstrUtils.secColor.getString()) + "[" + count + "]"; 21 | } 22 | 23 | @Override 24 | public int size() { 25 | return 1; 26 | } 27 | 28 | @Override 29 | public Expression clone() { 30 | return new NewArrayExpression(count.clone(), object); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NewPrimArrayExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class NewPrimArrayExpression extends Expression { 9 | private Expression count; 10 | private VarType type; 11 | 12 | public NewPrimArrayExpression(Expression count, VarType type) { 13 | super(); 14 | this.count = count; 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "new " + TextUtils.addTag(type.getType(), "font color=" + InstrUtils.secColor.getString()) + "[" + count + "]"; 21 | } 22 | 23 | @Override 24 | public int size() { 25 | return 1; 26 | } 27 | 28 | @Override 29 | public Expression clone() { 30 | return new NewPrimArrayExpression(count.clone(), type); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NewTypeExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.grax.jbytemod.analysis.decompiler.ClassDefinition; 6 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 7 | import me.grax.jbytemod.utils.InstrUtils; 8 | import me.grax.jbytemod.utils.TextUtils; 9 | 10 | public class NewTypeExpression extends Expression { 11 | private ClassDefinition object; 12 | private MethodExpression init; 13 | 14 | public NewTypeExpression(ClassDefinition object) { 15 | super(); 16 | this.object = object; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | if (init != null) { 22 | StringBuilder sb = new StringBuilder(); 23 | sb.append("new " + TextUtils.addTag(object.getName(), "font color=" + InstrUtils.secColor.getString())); 24 | sb.append("("); 25 | ArrayList argsString = new ArrayList<>(); 26 | for (Expression ref : init.getArgs()) { 27 | argsString.add(ref.toString()); 28 | } 29 | sb.append(String.join(", ", argsString)); 30 | sb.append(")"); 31 | return sb.toString(); 32 | } 33 | return "new " + TextUtils.addTag(object.getName(), "font color=" + InstrUtils.secColor.getString()); 34 | } 35 | 36 | @Override 37 | public int size() { 38 | return 1; 39 | } 40 | 41 | public Expression getInit() { 42 | return init; 43 | } 44 | 45 | public void setInit(MethodExpression init) { 46 | this.init = init; 47 | } 48 | 49 | @Override 50 | public Expression clone() { 51 | NewTypeExpression nte = new NewTypeExpression(object); 52 | if (init != null) { 53 | nte.setInit((MethodExpression) init.clone()); 54 | } 55 | return nte; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NotExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class NotExpression extends Expression { 6 | private Expression toNegate; 7 | 8 | public NotExpression(Expression toNegate) { 9 | super(); 10 | this.toNegate = toNegate; 11 | } 12 | 13 | public Expression getToNegate() { 14 | return toNegate; 15 | } 16 | 17 | public void setToNegate(Expression toNegate) { 18 | this.toNegate = toNegate; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "!(" + toNegate.toString() + ")"; 24 | } 25 | 26 | @Override 27 | public int size() { 28 | return toNegate.size(); 29 | } 30 | 31 | @Override 32 | public Expression clone() { 33 | return new NotExpression(toNegate.clone()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NullExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.defs.Keywords; 5 | 6 | public class NullExpression extends Expression { 7 | 8 | @Override 9 | public String toString() { 10 | return "" + Keywords.NULL + ""; 11 | } 12 | 13 | @Override 14 | public int size() { 15 | return 1; 16 | } 17 | 18 | @Override 19 | public Expression clone() { 20 | return new NullExpression(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/OpExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Operation; 5 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class OpExpression extends Expression { 9 | protected Expression left; 10 | private Expression right; 11 | protected Operation op; 12 | protected VarType returnType; 13 | 14 | public OpExpression(Expression left, Expression right, Operation op, VarType returnType) { 15 | super(); 16 | this.left = left; 17 | this.right = right; 18 | this.op = op; 19 | this.returnType = returnType; 20 | } 21 | 22 | public Expression getLeft() { 23 | return left; 24 | } 25 | 26 | public void setLeft(Expression left) { 27 | this.left = left; 28 | } 29 | 30 | public Expression getRight() { 31 | return right; 32 | } 33 | 34 | public void setRight(Expression right) { 35 | this.right = right; 36 | } 37 | 38 | public Operation getOp() { 39 | return op; 40 | } 41 | 42 | public void setOp(Operation op) { 43 | this.op = op; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return left.toString() + " " + TextUtils.escape(op.getSymbol()) + " " + right.toString(); 49 | } 50 | 51 | @Override 52 | public int size() { 53 | return returnType.size(); //right side defines the size 54 | } 55 | 56 | @Override 57 | public Expression clone() { 58 | return new OpExpression(left.clone(), right.clone(), op, returnType); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ReturnExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.defs.Keywords; 5 | 6 | public class ReturnExpression extends Expression { 7 | 8 | private Expression returnValue; 9 | 10 | public ReturnExpression(Expression returnValue) { 11 | super(); 12 | this.returnValue = returnValue; 13 | } 14 | 15 | public ReturnExpression() { 16 | super(); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | StringBuilder sb = new StringBuilder(); 22 | sb.append("" + Keywords.RETURN + ""); 23 | if (returnValue != null) { 24 | sb.append(" "); 25 | sb.append(returnValue); 26 | } 27 | return sb.toString(); 28 | } 29 | 30 | @Override 31 | public int size() { 32 | return 0; 33 | } 34 | 35 | @Override 36 | public Expression clone() { 37 | return new ReturnExpression(returnValue); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/SingleOpExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Operation; 5 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 6 | 7 | public class SingleOpExpression extends OpExpression { 8 | 9 | public SingleOpExpression(Expression ref, Operation op, VarType returnType) { 10 | super(ref, null, op, returnType); 11 | } 12 | 13 | @Override 14 | public Expression getRight() { 15 | throw new IllegalArgumentException("called getRight on single exp reference"); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return op.getSymbol() + "(" + left.toString() + ")"; 21 | } 22 | 23 | @Override 24 | public Expression clone() { 25 | return new SingleOpExpression(left.clone(), op, returnType); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/StringExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class StringExpression extends Expression { 7 | 8 | private String value; 9 | 10 | public StringExpression(String value) { 11 | super(); 12 | this.value = value; 13 | } 14 | 15 | public String getValue() { 16 | return value; 17 | } 18 | 19 | public void setValue(String value) { 20 | this.value = value; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return TextUtils.addTag("\"" + value + "\"", "font color=#559955"); //TODO escape 26 | } 27 | 28 | @Override 29 | public int size() { 30 | return 1; 31 | } 32 | 33 | @Override 34 | public Expression clone() { 35 | return new StringExpression(value); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/TableSwitchExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class TableSwitchExpression extends Expression { 6 | 7 | private Expression toSwitch; 8 | private int min; 9 | private int max; 10 | 11 | public TableSwitchExpression(Expression toSwitch, int min, int max) { 12 | this.toSwitch = toSwitch; 13 | this.min = min; 14 | this.max = max; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "switch(" + toSwitch + ") " + min + " - " + max + ""; 20 | } 21 | 22 | @Override 23 | public int size() { 24 | return 1; 25 | } 26 | 27 | @Override 28 | public Expression clone() { 29 | return new TableSwitchExpression(toSwitch.clone(), min, max); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/TextExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class TextExpression extends Expression { 7 | 8 | private String text; 9 | 10 | public TextExpression(String var) { 11 | this.text = var; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "" + TextUtils.escape(text) + ""; 17 | } 18 | 19 | @Override 20 | public int size() { 21 | return 0; 22 | } 23 | 24 | @Override 25 | public Expression clone() { 26 | return new TextExpression(text); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ThrowExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.defs.Keywords; 5 | 6 | public class ThrowExpression extends Expression { 7 | 8 | private Expression throwable; 9 | 10 | public ThrowExpression(Expression throwable) { 11 | super(); 12 | this.throwable = throwable; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | StringBuilder sb = new StringBuilder(); 18 | sb.append("" + Keywords.THROW + ""); 19 | if (throwable != null) { 20 | sb.append(" "); 21 | sb.append(throwable); 22 | } 23 | return sb.toString(); 24 | } 25 | 26 | @Override 27 | public int size() { 28 | return 0; 29 | } 30 | 31 | @Override 32 | public Expression clone() { 33 | return new ThrowExpression(throwable); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ValueExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | 6 | public class ValueExpression extends Expression { 7 | private VarType type; 8 | private Object value; 9 | 10 | public ValueExpression(VarType type, Object value) { 11 | super(); 12 | this.type = type; 13 | this.value = value; 14 | } 15 | 16 | private String getSub() { 17 | switch (type) { 18 | case OBJECT: 19 | case INT: 20 | return ""; 21 | case DOUBLE: 22 | return "d"; 23 | case FLOAT: 24 | return "f"; 25 | case LONG: 26 | return "L"; 27 | default: 28 | return ""; 29 | } 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return value.toString() + getSub(); 35 | } 36 | 37 | @Override 38 | public int size() { 39 | return type.size(); 40 | } 41 | 42 | @Override 43 | public Expression clone() { 44 | return new ValueExpression(type, value); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/VarAssignExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class VarAssignExpression extends Expression { 9 | private int index; 10 | private VarType type; 11 | private Expression value; 12 | 13 | public VarAssignExpression(int index, VarType type, Expression value) { 14 | super(); 15 | this.index = index; 16 | this.type = type; 17 | this.value = value; 18 | } 19 | 20 | public int getIndex() { 21 | return index; 22 | } 23 | 24 | public void setIndex(int index) { 25 | this.index = index; 26 | } 27 | 28 | public VarType getType() { 29 | return type; 30 | } 31 | 32 | public void setType(VarType type) { 33 | this.type = type; 34 | } 35 | 36 | public Expression getValue() { 37 | return value; 38 | } 39 | 40 | public void setValue(Expression value) { 41 | this.value = value; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | StringBuilder sb = new StringBuilder(); 47 | sb.append(type.getType()); 48 | sb.append(" "); 49 | sb.append(TextUtils.addTag("var" + index, "font color=" + InstrUtils.primColor.getString())); 50 | sb.append(" = "); 51 | sb.append(value.toString()); 52 | return sb.toString(); 53 | } 54 | 55 | @Override 56 | public int size() { 57 | return 0; 58 | } 59 | 60 | @Override 61 | public Expression clone() { 62 | return new VarAssignExpression(index, type, value.clone()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/VarLoadExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class VarLoadExpression extends Expression { 9 | private int index; 10 | private VarType type; 11 | 12 | public VarLoadExpression(int index, VarType type) { 13 | super(); 14 | this.index = index; 15 | this.type = type; 16 | } 17 | 18 | public int getIndex() { 19 | return index; 20 | } 21 | 22 | public void setIndex(int index) { 23 | this.index = index; 24 | } 25 | 26 | public VarType getType() { 27 | return type; 28 | } 29 | 30 | public void setType(VarType type) { 31 | this.type = type; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return TextUtils.addTag("var" + index, "font color=" + InstrUtils.primColor.getString()); //TODO use localvartable 37 | } 38 | 39 | @Override 40 | public int size() { 41 | return type.size(); 42 | } 43 | 44 | @Override 45 | public Expression clone() { 46 | return new VarLoadExpression(index, type); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/VarSpecialExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class VarSpecialExpression extends Expression { 7 | 8 | private String var; 9 | 10 | public VarSpecialExpression(String var) { 11 | this.var = var; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return TextUtils.addTag(var, "font color=#669966"); 17 | } 18 | 19 | @Override 20 | public int size() { 21 | return 1; 22 | } 23 | 24 | @Override 25 | public Expression clone() { 26 | return new VarSpecialExpression(var); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/defs/Keywords.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.defs; 2 | 3 | public class Keywords { 4 | public static final String RETURN = "return"; 5 | public static final String THROW = "throw"; 6 | public static final String NULL = "null"; 7 | //TODO add other keywords 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/struct/exception/StackException.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.struct.exception; 2 | 3 | public class StackException extends RuntimeException { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public StackException(String string) { 7 | super(string); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/struct/exception/UnknownOPException.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.struct.exception; 2 | 3 | import me.lpk.util.OpUtils; 4 | 5 | public class UnknownOPException extends RuntimeException { 6 | private static final long serialVersionUID = 1L; 7 | 8 | public UnknownOPException(int opc) { 9 | super("Unresolved opcode: " + OpUtils.getOpcodeText(opc) + " (" + opc + ")"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/struct/utils/DescUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.struct.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class DescUtils { 6 | public static ArrayList getDescSizes(String desc) { 7 | ArrayList descSizes = new ArrayList<>(); 8 | int dims = 0; 9 | boolean inObject = false; 10 | for (char c : desc.toCharArray()) { 11 | if (inObject) { 12 | if (c == ';') { 13 | inObject = false; 14 | descSizes.add(1); 15 | dims = 0; 16 | } 17 | continue; 18 | } 19 | if (c == 'L') { 20 | inObject = true; 21 | } else if (c == '[') { 22 | dims++; 23 | } else { 24 | if (dims == 0 && (c == 'J' || c == 'D')) { 25 | descSizes.add(2); 26 | } else { 27 | descSizes.add(1); 28 | } 29 | dims = 0; 30 | } 31 | } 32 | return descSizes; 33 | } 34 | 35 | public static ArrayList getInnerDescSizes(String desc) { 36 | if (desc.startsWith("()")) { 37 | return new ArrayList<>(); 38 | } 39 | return getDescSizes(desc.substring(1, desc.lastIndexOf(')'))); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/syntax/nodes/NodeList.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.syntax.nodes; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 6 | 7 | public class NodeList extends ArrayList { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/EmptyMistake.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public class EmptyMistake extends Mistake { 4 | public EmptyMistake() { 5 | super(" "); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/InsnError.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public class InsnError extends Mistake { 4 | 5 | public InsnError(String desc) { 6 | super(desc); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/InsnWarning.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public class InsnWarning extends Mistake { 4 | 5 | public InsnWarning(String desc) { 6 | super(desc); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/Mistake.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public abstract class Mistake { 4 | private String desc; 5 | 6 | public Mistake(String desc) { 7 | this.desc = desc; 8 | } 9 | 10 | public String getDesc() { 11 | return desc; 12 | } 13 | 14 | public void setDesc(String desc) { 15 | this.desc = desc; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/enums/MethodObfType.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.enums; 2 | 3 | public enum MethodObfType { 4 | NONE("None"), TCBO("Unneccesary TCBs"), POP2( 5 | "POP2 Exploit")/* , LOCAL_VAR("Local Var Obf") */, STRING("String Obfuscation"), INVOKEDYNAMIC("Invokedynamic"); 6 | 7 | private final String type; 8 | 9 | private MethodObfType(String type) { 10 | this.type = type; 11 | } 12 | 13 | public String getType() { 14 | return type; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/enums/NameObfType.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.enums; 2 | 3 | public enum NameObfType { 4 | NONE("None"), LONG_LETTERS("Long Letters"), SHORT_LETTERS("Short Letters"), HIGH_CHAR("High UTF8 Values"), JAVA_KEYWORD( 5 | "Java Keywords"), INVALID_WINDIR("Invalid Dir Names"); 6 | 7 | private final String type; 8 | 9 | private NameObfType(String type) { 10 | this.type = type; 11 | } 12 | 13 | public String getType() { 14 | return type; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/result/MethodResult.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.result; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.grax.jbytemod.analysis.obfuscation.enums.MethodObfType; 6 | 7 | public class MethodResult { 8 | public ArrayList mobf; 9 | 10 | public MethodResult(ArrayList mobf) { 11 | super(); 12 | this.mobf = mobf; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/result/NamesResult.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.result; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.grax.jbytemod.analysis.obfuscation.enums.NameObfType; 6 | 7 | public class NamesResult { 8 | public ArrayList cnames; 9 | public ArrayList mnames; 10 | public ArrayList fnames; 11 | 12 | public NamesResult(ArrayList cnames, ArrayList mnames, ArrayList fnames) { 13 | super(); 14 | this.cnames = cnames; 15 | this.mnames = mnames; 16 | this.fnames = fnames; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/utils/BlockUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | import me.grax.jbytemod.analysis.block.Block; 6 | 7 | public class BlockUtils { 8 | public static boolean doesMerge(Block block, Block into) { 9 | return doesMerge(new ArrayList<>(), block, into); 10 | } 11 | 12 | private static boolean doesMerge(ArrayList visited, Block block, Block into) { 13 | if (visited.contains(block)) { 14 | return false; 15 | } 16 | visited.add(block); 17 | if (block == into) { 18 | return true; 19 | } 20 | for (Block output : block.getOutput()) { 21 | if (doesMerge(visited, output, into)) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/decompiler/Decompiler.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.decompiler; 2 | 3 | import org.objectweb.asm.ClassWriter; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.objectweb.asm.tree.MethodNode; 6 | 7 | import me.grax.jbytemod.JByteMod; 8 | import me.grax.jbytemod.ui.DecompilerPanel; 9 | 10 | public abstract class Decompiler extends Thread { 11 | protected JByteMod jbm; 12 | protected ClassNode cn; 13 | protected DecompilerPanel dp; 14 | private MethodNode mn; 15 | /** 16 | * Do not reload if we already know the output 17 | */ 18 | public static ClassNode last; 19 | public static MethodNode lastMn; 20 | public static String lastOutput; 21 | 22 | public Decompiler(JByteMod jbm, DecompilerPanel dp) { 23 | this.jbm = jbm; 24 | this.dp = dp; 25 | } 26 | 27 | public Decompiler setNode(ClassNode cn, MethodNode mn) { 28 | this.cn = cn; 29 | this.mn = mn; 30 | return this; 31 | } 32 | 33 | public Decompiler deleteCache() { 34 | last = null; 35 | return this; 36 | } 37 | 38 | @Override 39 | public final void run() { 40 | dp.setText("Loading..."); 41 | if (cn == null) { 42 | dp.setText("ClassNode is null."); 43 | return; 44 | } 45 | dp.setText(lastOutput = this.decompile(cn, mn)); 46 | } 47 | 48 | protected String decompile(ClassNode cn, MethodNode mn) { 49 | if (last != null && cn.equals(last) 50 | && ((lastMn == null && mn == null) || (mn != null && lastMn != null && mn.equals(lastMn)))) { 51 | // same node, same output 52 | return lastOutput; 53 | } 54 | last = cn; 55 | lastMn = mn; 56 | // do not regenerate anything here 57 | ClassWriter cw = new ClassWriter(0); 58 | cn.accept(cw); 59 | return decompile(cw.toByteArray(), mn); 60 | } 61 | 62 | protected abstract String decompile(byte[] b, MethodNode mn); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/decompiler/Decompilers.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.decompiler; 2 | 3 | public enum Decompilers { 4 | PROCYON("Procyon", "0.5.32"), FERNFLOWER("Fernflower", ""), CFR("CFR", "1.39"), KRAKATAU("Krakatau", "502"); 5 | private String version; 6 | private String name; 7 | 8 | Decompilers(String name, String version) { 9 | this.name = name; 10 | this.version = version; 11 | } 12 | 13 | public String getVersion() { 14 | return version; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return name + " " + version; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/plugin/Plugin.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.plugin; 2 | 3 | import java.util.Map; 4 | 5 | import javax.swing.JMenuBar; 6 | import javax.swing.JTree; 7 | 8 | import org.objectweb.asm.tree.ClassNode; 9 | import org.objectweb.asm.tree.MethodNode; 10 | 11 | import me.grax.jbytemod.JByteMod; 12 | 13 | public abstract class Plugin { 14 | protected String name; 15 | protected String version; 16 | protected String author; 17 | 18 | public Plugin(String name, String version, String author) { 19 | this.name = name; 20 | this.version = version; 21 | this.author = author; 22 | } 23 | 24 | public abstract void init(); 25 | 26 | public abstract void loadFile(Map map); 27 | 28 | public abstract boolean isClickable(); 29 | 30 | public abstract void menuClick(); 31 | 32 | protected final Map getCurrentFile() { 33 | return JByteMod.instance.getFile().getClasses(); 34 | } 35 | 36 | protected final void updateTree() { 37 | JByteMod.instance.refreshTree(); 38 | } 39 | 40 | protected final JMenuBar getMenu() { 41 | return JByteMod.instance.getMyMenuBar(); 42 | } 43 | 44 | protected final JTree gerTree() { 45 | return JByteMod.instance.getJarTree(); 46 | } 47 | 48 | protected final ClassNode gerSelectedNode() { 49 | return JByteMod.instance.getCurrentNode(); 50 | } 51 | 52 | protected final MethodNode gerSelectedMethod() { 53 | return JByteMod.instance.getCurrentMethod(); 54 | } 55 | 56 | public final String getName() { 57 | return name; 58 | } 59 | 60 | public final String getVersion() { 61 | return version; 62 | } 63 | 64 | public final String getAuthor() { 65 | return author; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/res/Option.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.res; 2 | 3 | public class Option { 4 | 5 | private String name; 6 | private String group; 7 | 8 | private Object value; 9 | private Type type; 10 | 11 | public Option(String name, Object value, Type type) { 12 | this(name, value, type, "general"); 13 | } 14 | 15 | public Option(String name, Object value, Type type, String group) { 16 | this.name = name; 17 | switch (type) { 18 | case INT: 19 | this.value = Integer.parseInt(value.toString()); 20 | break; 21 | case BOOLEAN: 22 | this.value = Boolean.parseBoolean(value.toString()); 23 | break; 24 | default: 25 | this.value = value; 26 | break; 27 | } 28 | this.type = type; 29 | this.group = group; 30 | } 31 | 32 | public boolean getBoolean() { 33 | return (boolean) value; 34 | } 35 | 36 | public String getString() { 37 | return (String) value; 38 | } 39 | 40 | public int getInteger() { 41 | return (int) value; 42 | } 43 | 44 | public void setValue(Object value) { 45 | this.value = value; 46 | } 47 | 48 | public String getGroup() { 49 | return group; 50 | } 51 | 52 | public void setGroup(String group) { 53 | this.group = group; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | 64 | public Object getValue() { 65 | return value; 66 | } 67 | 68 | public Type getType() { 69 | return type; 70 | } 71 | 72 | public void setType(Type type) { 73 | this.type = type; 74 | } 75 | 76 | public enum Type { 77 | BOOLEAN, STRING, INT 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/DecompilerPanel.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.awt.Font; 4 | import java.io.IOException; 5 | 6 | import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; 7 | import org.fife.ui.rsyntaxtextarea.Theme; 8 | 9 | import me.grax.jbytemod.utils.ErrorDisplay; 10 | 11 | public class DecompilerPanel extends RSyntaxTextArea { 12 | 13 | public DecompilerPanel() { 14 | this.setSyntaxEditingStyle("text/java"); 15 | this.setCodeFoldingEnabled(true); 16 | this.setAntiAliasingEnabled(true); 17 | this.setFont(new Font("Monospaced", Font.PLAIN, 12)); 18 | this.setEditable(false); 19 | //change theme to java 20 | try { 21 | Theme theme = Theme.load(getClass().getResourceAsStream("/org/fife/ui/rsyntaxtextarea/themes/idea.xml")); 22 | theme.apply(this); 23 | } catch (IOException e1) { 24 | new ErrorDisplay(e1); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/JMethodObfAnalysis.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.util.Map; 4 | 5 | import org.jfree.data.category.CategoryDataset; 6 | import org.jfree.data.category.DefaultCategoryDataset; 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import me.grax.jbytemod.analysis.obfuscation.enums.MethodObfType; 10 | import me.grax.jbytemod.analysis.obfuscation.result.MethodResult; 11 | 12 | public class JMethodObfAnalysis extends JObfAnalysis { 13 | 14 | public JMethodObfAnalysis(Map nodes) { 15 | super(nodes); 16 | } 17 | 18 | protected CategoryDataset analyze(Map nodes) { 19 | MethodResult mr = analyzer.analyzeMethod(); 20 | final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 21 | for (MethodObfType t : MethodObfType.values()) { 22 | if (t == MethodObfType.NONE) 23 | continue; 24 | int i = 0; 25 | for (MethodObfType not : mr.mobf) { 26 | if (not == t) { 27 | i++; 28 | } 29 | } 30 | dataset.addValue((double) (i / (double) mr.mobf.size()) * 100d, "", t.getType()); 31 | } 32 | return dataset; 33 | } 34 | 35 | @Override 36 | protected String[] getDescriptors() { 37 | return new String[] { "Method Obfuscation", "Categories", "Percent" }; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/JNameObfAnalysis.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.util.Map; 4 | 5 | import org.jfree.data.category.CategoryDataset; 6 | import org.jfree.data.category.DefaultCategoryDataset; 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import me.grax.jbytemod.analysis.obfuscation.enums.NameObfType; 10 | import me.grax.jbytemod.analysis.obfuscation.result.NamesResult; 11 | 12 | public class JNameObfAnalysis extends JObfAnalysis { 13 | 14 | public JNameObfAnalysis(Map nodes) { 15 | super(nodes); 16 | } 17 | 18 | protected CategoryDataset analyze(Map nodes) { 19 | NamesResult nr = analyzer.analyzeNames(); 20 | final String clazzes = "Classes"; 21 | final String methods = "Methods"; 22 | final String fields = "Fields"; 23 | 24 | final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 25 | for (NameObfType t : NameObfType.values()) { 26 | if (t == NameObfType.NONE) 27 | continue; 28 | int i = 0; 29 | for (NameObfType not : nr.cnames) { 30 | if (not == t) { 31 | i++; 32 | } 33 | } 34 | dataset.addValue((double) (i / (double) nr.cnames.size()) * 100d, clazzes, t.getType()); 35 | i = 0; 36 | for (NameObfType not : nr.mnames) { 37 | if (not == t) { 38 | i++; 39 | } 40 | } 41 | dataset.addValue((double) (i / (double) nr.mnames.size()) * 100d, methods, t.getType()); 42 | i = 0; 43 | for (NameObfType not : nr.fnames) { 44 | if (not == t) { 45 | i++; 46 | } 47 | } 48 | dataset.addValue((double) (i / (double) nr.fnames.size()) * 100d, fields, t.getType()); 49 | } 50 | return dataset; 51 | } 52 | 53 | @Override 54 | protected String[] getDescriptors() { 55 | return new String[] { "Name Obfuscation", "Categories", "Percent" }; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/JObfAnalysis.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.util.Map; 5 | 6 | import javax.swing.JFrame; 7 | import javax.swing.JPanel; 8 | 9 | import org.jfree.chart.ChartFactory; 10 | import org.jfree.chart.ChartPanel; 11 | import org.jfree.chart.JFreeChart; 12 | import org.jfree.data.category.CategoryDataset; 13 | import org.objectweb.asm.tree.ClassNode; 14 | 15 | import me.grax.jbytemod.analysis.obfuscation.ObfuscationAnalyzer; 16 | 17 | public abstract class JObfAnalysis extends JFrame { 18 | protected ObfuscationAnalyzer analyzer; 19 | 20 | public JObfAnalysis(Map nodes) { 21 | setBounds(100, 100, 800, 800); 22 | setResizable(false); 23 | setTitle("Obfuscation Analysis"); 24 | JPanel cp = new JPanel(); 25 | cp.setLayout(new BorderLayout()); 26 | this.analyzer = new ObfuscationAnalyzer(nodes); 27 | cp.add(new ChartPanel(createChart(analyze(nodes))), BorderLayout.CENTER); 28 | this.add(cp); 29 | 30 | } 31 | 32 | protected abstract CategoryDataset analyze(Map nodes); 33 | 34 | protected abstract String[] getDescriptors(); 35 | 36 | private JFreeChart createChart(CategoryDataset categoryDataset) { 37 | String[] desc = getDescriptors(); 38 | JFreeChart chart = ChartFactory.createBarChart(desc[0], desc[1], desc[2], categoryDataset); 39 | return chart; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/MyCodeEditor.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.awt.BorderLayout; 4 | 5 | import javax.swing.BorderFactory; 6 | import javax.swing.JLabel; 7 | import javax.swing.JPanel; 8 | 9 | import me.grax.jbytemod.JByteMod; 10 | import me.grax.jbytemod.ui.lists.AdressList; 11 | import me.grax.jbytemod.ui.lists.ErrorList; 12 | import me.grax.jbytemod.ui.lists.MyCodeList; 13 | 14 | public class MyCodeEditor extends JPanel { 15 | private MyCodeList cl; 16 | 17 | public MyCodeEditor(JByteMod jbm, JLabel editor) { 18 | this.setLayout(new BorderLayout()); 19 | cl = new MyCodeList(jbm, editor); 20 | this.add(cl, BorderLayout.CENTER); 21 | JPanel p = new JPanel(); 22 | p.setLayout(new BorderLayout()); 23 | p.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, JByteMod.border)); 24 | p.add(new AdressList(cl), BorderLayout.CENTER); 25 | this.add(p, BorderLayout.WEST); 26 | this.add(new ErrorList(jbm, cl), BorderLayout.EAST); 27 | 28 | } 29 | 30 | public MyCodeList getEditor() { 31 | return cl; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/MySplitPane.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.awt.BorderLayout; 4 | 5 | import javax.swing.JLabel; 6 | import javax.swing.JPanel; 7 | import javax.swing.JScrollPane; 8 | import javax.swing.JSplitPane; 9 | import javax.swing.JTabbedPane; 10 | 11 | import me.grax.jbytemod.JByteMod; 12 | 13 | public class MySplitPane extends JSplitPane { 14 | private JTabbedPane rightSide; 15 | private JPanel leftSide; 16 | 17 | public MySplitPane(JByteMod jbm, ClassTree classTree) { 18 | rightSide = new MyTabbedPane(jbm); 19 | leftSide = new JPanel(); 20 | leftSide.setLayout(new BorderLayout(0, 0)); 21 | leftSide.add(new JLabel(" " + JByteMod.res.getResource("java_archive")), BorderLayout.NORTH); 22 | leftSide.add(new JScrollPane(classTree), BorderLayout.CENTER); 23 | this.setLeftComponent(leftSide); 24 | this.setRightComponent(rightSide); 25 | this.setDividerLocation(150); 26 | this.setContinuousLayout(true); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/NoBorderSP.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.awt.Component; 4 | 5 | import javax.swing.BorderFactory; 6 | import javax.swing.JScrollPane; 7 | 8 | public class NoBorderSP extends JScrollPane { 9 | public NoBorderSP(Component c) { 10 | super(c); 11 | this.setBorder(BorderFactory.createEmptyBorder()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/OpcodeTable.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import java.awt.Font; 4 | 5 | import javax.swing.JEditorPane; 6 | 7 | import org.apache.commons.io.IOUtils; 8 | 9 | import me.grax.jbytemod.utils.ErrorDisplay; 10 | 11 | public class OpcodeTable extends JEditorPane { 12 | public OpcodeTable() { 13 | this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13)); 14 | this.setEditable(false); 15 | this.setContentType("text/html"); 16 | this.setText(loadTable()); 17 | } 18 | 19 | private String loadTable() { 20 | try { 21 | return IOUtils.toString(this.getClass().getResourceAsStream("/resources/html/optable.html")); 22 | } catch (Exception e) { 23 | new ErrorDisplay(e); 24 | return ""; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/dialogue/testing/TestValues.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.dialogue.testing; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | import me.grax.jbytemod.JByteMod; 8 | import me.grax.jbytemod.ui.dialogue.InsnEditDialogue; 9 | 10 | public class TestValues { 11 | public int integer = 0; 12 | public float floatval = 0; 13 | public double doubleval = 0; 14 | public long longval = 0; 15 | public byte byteval = 0; 16 | public char charval = 'c'; 17 | public short shortval = 0; 18 | public Integer integer2 = 0; 19 | public Float floatval2 = 0f; 20 | public Double doubleval2 = 0d; 21 | public Long longval2 = 0L; 22 | public Byte byteval2 = 0; 23 | public Character charval2 = 0; 24 | public Short shortval2 = 0; 25 | public String test = "Test"; 26 | /* public String stringNull = null; */ 27 | public List list = Arrays.asList("1", "2", "3"); 28 | 29 | public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException { 30 | JByteMod.initialize(); 31 | TestValues tv = new TestValues(); 32 | new InsnEditDialogue(null, tv).open(); 33 | for(Field f : tv.getClass().getDeclaredFields()) { 34 | System.out.println(f.getName() + " " + f.get(tv)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/graph/PatchedHierarchicalLayout.java: -------------------------------------------------------------------------------- 1 | // Copyright GFI 2017 - Data Systemizer 2 | package me.grax.jbytemod.ui.graph; 3 | 4 | import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; 5 | import com.mxgraph.layout.hierarchical.stage.mxCoordinateAssignment; 6 | import com.mxgraph.view.mxGraph; 7 | 8 | /** 9 | * Patched hierarchical layout to route directly cross-group edges 10 | * 11 | * @author Loison 12 | * 13 | */ 14 | public class PatchedHierarchicalLayout extends mxHierarchicalLayout { 15 | 16 | public PatchedHierarchicalLayout(mxGraph graph) { 17 | super(graph); 18 | } 19 | 20 | public PatchedHierarchicalLayout(mxGraph graph, int orientation) { 21 | super(graph, orientation); 22 | } 23 | 24 | /** 25 | * Executes the placement stage using mxCoordinateAssignment. 26 | *

27 | * Use a patched mxCoordinateAssignment class 28 | */ 29 | @Override 30 | public double placementStage(double initialX, Object parent) { 31 | mxCoordinateAssignment placementStage = new PatchedCoordinateAssignment(this, intraCellSpacing, interRankCellSpacing, orientation, initialX, 32 | parallelEdgeSpacing); 33 | placementStage.setFineTuning(fineTuning); 34 | placementStage.execute(parent); 35 | 36 | return placementStage.getLimitX() + interHierarchySpacing; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/ifs/LVPFrame.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.ifs; 2 | 3 | import java.awt.Rectangle; 4 | 5 | import me.grax.jbytemod.ui.NoBorderSP; 6 | import me.grax.jbytemod.ui.lists.LVPList; 7 | 8 | public class LVPFrame extends MyInternalFrame { 9 | /** 10 | * Save position 11 | */ 12 | private static Rectangle bounds = new Rectangle(10, 10, 1280 / 4, 720 / 4); 13 | 14 | public LVPFrame(LVPList lvp) { 15 | super("Local Variables"); 16 | this.add(new NoBorderSP(lvp)); 17 | this.setBounds(bounds); 18 | this.show(); 19 | } 20 | 21 | @Override 22 | public void setVisible(boolean aFlag) { 23 | if (!aFlag && !(getLocation().getY() == 0 && getLocation().getX() == 0)) { 24 | bounds = getBounds(); 25 | } 26 | super.setVisible(aFlag); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/ifs/MyInternalFrame.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.ifs; 2 | 3 | import javax.swing.JInternalFrame; 4 | 5 | public class MyInternalFrame extends JInternalFrame { 6 | 7 | public MyInternalFrame(String title) { 8 | this.setTitle(title); 9 | this.setMaximizable(true); 10 | this.setResizable(true); 11 | this.setClosable(false); 12 | this.setIconifiable(true); 13 | getDesktopIcon().updateUI(); 14 | updateUI(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/ifs/TCBFrame.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.ifs; 2 | 3 | import java.awt.Rectangle; 4 | 5 | import me.grax.jbytemod.ui.NoBorderSP; 6 | import me.grax.jbytemod.ui.lists.TCBList; 7 | 8 | public class TCBFrame extends MyInternalFrame { 9 | /** 10 | * Save position 11 | */ 12 | private static Rectangle bounds = new Rectangle(340, 10, 1280 / 4, 720 / 4); 13 | 14 | public TCBFrame(TCBList tcb) { 15 | super("Try Catch Blocks"); 16 | this.add(new NoBorderSP(tcb)); 17 | this.setBounds(bounds); 18 | this.show(); 19 | } 20 | 21 | @Override 22 | public void setVisible(boolean aFlag) { 23 | if (!aFlag && !(getLocation().getY() == 0 && getLocation().getX() == 0)) { 24 | bounds = getBounds(); 25 | } 26 | super.setVisible(aFlag); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/AdressList.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists; 2 | 3 | import java.awt.Font; 4 | 5 | import javax.swing.DefaultListModel; 6 | import javax.swing.DefaultListSelectionModel; 7 | import javax.swing.JList; 8 | 9 | import me.grax.jbytemod.ui.lists.entries.InstrEntry; 10 | import me.grax.jbytemod.utils.gui.SwingUtils; 11 | import me.grax.jbytemod.utils.list.LazyListModel; 12 | 13 | public class AdressList extends JList { 14 | private MyCodeList cl; 15 | 16 | public AdressList(MyCodeList cl) { 17 | super(new DefaultListModel()); 18 | this.cl = cl; 19 | cl.setAdressList(this); 20 | this.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); 21 | this.updateAdr(); 22 | this.setSelectionModel(new DefaultListSelectionModel() { 23 | @Override 24 | public void setSelectionInterval(int index0, int index1) { 25 | super.setSelectionInterval(-1, -1); 26 | } 27 | }); 28 | this.setPrototypeCellValue("0000"); 29 | SwingUtils.disableSelection(this); 30 | } 31 | 32 | public void updateAdr() { 33 | LazyListModel lm = new LazyListModel(); 34 | LazyListModel clm = (LazyListModel) cl.getModel(); 35 | if (clm.getSize() > 9999) { 36 | throw new RuntimeException("code too big"); 37 | } 38 | for (int i = 0; i < clm.getSize(); i++) { 39 | String hex = String.valueOf(i); 40 | lm.addElement("0000".substring(hex.length()) + hex); 41 | } 42 | this.setModel(lm); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/FieldEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import org.objectweb.asm.tree.FieldNode; 5 | 6 | import me.grax.jbytemod.utils.InstrUtils; 7 | import me.grax.jbytemod.utils.TextUtils; 8 | 9 | public class FieldEntry extends InstrEntry { 10 | 11 | private ClassNode cn; 12 | private FieldNode fn; 13 | private String text; 14 | private String easyText; 15 | 16 | public FieldEntry(ClassNode cn, FieldNode fn) { 17 | super(null, null); 18 | this.cn = cn; 19 | this.fn = fn; 20 | this.text = TextUtils 21 | .toHtml(InstrUtils.getDisplayAccess(fn.access) + " " + InstrUtils.getDisplayType(fn.desc, true) + " " + InstrUtils.getDisplayClassRed(fn.name) 22 | + " = " + (fn.value instanceof String ? TextUtils.addTag("\"" + TextUtils.escape(String.valueOf(fn.value)) + "\"", "font color=#559955") 23 | : fn.value != null ? String.valueOf(fn.value) : TextUtils.toBold("null"))); 24 | this.easyText = InstrUtils.getDisplayAccess(fn.access) + " " + InstrUtils.getDisplayType(fn.desc, false) + " " 25 | + InstrUtils.getDisplayClassEasy(fn.name) + " = " 26 | + (fn.value instanceof String ? "\"" + String.valueOf(fn.value) + "\"" : String.valueOf(fn.value)); 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return text; 32 | } 33 | 34 | public ClassNode getCn() { 35 | return cn; 36 | } 37 | 38 | public void setCn(ClassNode cn) { 39 | this.cn = cn; 40 | } 41 | 42 | public FieldNode getFn() { 43 | return fn; 44 | } 45 | 46 | public void setFn(FieldNode fn) { 47 | this.fn = fn; 48 | } 49 | 50 | public String toEasyString() { 51 | return easyText; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/InstrEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import org.objectweb.asm.tree.AbstractInsnNode; 4 | import org.objectweb.asm.tree.MethodNode; 5 | 6 | import me.grax.jbytemod.utils.InstrUtils; 7 | import me.grax.jbytemod.utils.TextUtils; 8 | import me.grax.jbytemod.utils.asm.Hints; 9 | 10 | public class InstrEntry { 11 | private MethodNode m; 12 | private AbstractInsnNode i; 13 | 14 | public MethodNode getMethod() { 15 | return m; 16 | } 17 | 18 | public void setM(MethodNode m) { 19 | this.m = m; 20 | } 21 | 22 | public AbstractInsnNode getInstr() { 23 | return i; 24 | } 25 | 26 | public void setI(AbstractInsnNode i) { 27 | this.i = i; 28 | } 29 | 30 | public InstrEntry(MethodNode m, AbstractInsnNode i) { 31 | this.m = m; 32 | this.i = (AbstractInsnNode) i; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return TextUtils.toHtml(InstrUtils.toString(i)); 38 | } 39 | 40 | public String toEasyString() { 41 | return InstrUtils.toEasyString(i); 42 | } 43 | 44 | public String getHint() { 45 | if (i != null && i.getOpcode() >= 0) { 46 | return Hints.hints[i.getOpcode()]; 47 | } 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/LVPEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import org.objectweb.asm.tree.LocalVariableNode; 5 | import org.objectweb.asm.tree.MethodNode; 6 | 7 | import me.grax.jbytemod.utils.InstrUtils; 8 | import me.grax.jbytemod.utils.TextUtils; 9 | 10 | public class LVPEntry { 11 | private ClassNode cn; 12 | private MethodNode mn; 13 | private LocalVariableNode lvn; 14 | private String text; 15 | 16 | public ClassNode getCn() { 17 | return cn; 18 | } 19 | 20 | public MethodNode getMn() { 21 | return mn; 22 | } 23 | 24 | public LVPEntry(ClassNode cn, MethodNode mn, LocalVariableNode lvn) { 25 | this.cn = cn; 26 | this.mn = mn; 27 | this.lvn = lvn; 28 | this.text = TextUtils.toHtml(TextUtils.toBold("#" + lvn.index) + " "); 29 | if (lvn.desc != null && !lvn.desc.isEmpty()) { 30 | this.text += InstrUtils.getDisplayType(lvn.desc, true) + " "; 31 | } 32 | this.text += TextUtils.addTag(TextUtils.escape(lvn.name), "font color=#995555"); 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return text; 38 | } 39 | 40 | public LocalVariableNode getLvn() { 41 | return lvn; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/PrototypeEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | public class PrototypeEntry extends InstrEntry { 4 | 5 | public PrototypeEntry() { 6 | super(null, null); 7 | } 8 | 9 | @Override 10 | public String toString() { 11 | return " "; 12 | } 13 | 14 | @Override 15 | public String toEasyString() { 16 | return " "; 17 | } 18 | 19 | @Override 20 | public String getHint() { 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/TCBEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import org.objectweb.asm.tree.MethodNode; 5 | import org.objectweb.asm.tree.TryCatchBlockNode; 6 | 7 | import me.grax.jbytemod.utils.InstrUtils; 8 | import me.grax.jbytemod.utils.TextUtils; 9 | import me.lpk.util.OpUtils; 10 | 11 | public class TCBEntry { 12 | private ClassNode cn; 13 | private MethodNode mn; 14 | private TryCatchBlockNode tcbn; 15 | private String text; 16 | 17 | public ClassNode getCn() { 18 | return cn; 19 | } 20 | 21 | public MethodNode getMn() { 22 | return mn; 23 | } 24 | 25 | public TCBEntry(ClassNode cn, MethodNode mn, TryCatchBlockNode tcbn) { 26 | this.cn = cn; 27 | this.mn = mn; 28 | this.tcbn = tcbn; 29 | this.text = TextUtils.toHtml( 30 | (tcbn.type != null ? InstrUtils.getDisplayType(tcbn.type, true) : TextUtils.addTag("Null type", "font color=" + InstrUtils.primColor.getString())) + ": label " + OpUtils.getLabelIndex(tcbn.start) + " -> label " 31 | + OpUtils.getLabelIndex(tcbn.end) + " handler: label " + (tcbn.handler == null ? "null" : OpUtils.getLabelIndex(tcbn.handler))); 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return text; 37 | } 38 | 39 | public TryCatchBlockNode getTcbn() { 40 | return tcbn; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils; 2 | 3 | import java.io.File; 4 | 5 | public class FileUtils { 6 | public static boolean exists(File f) { 7 | return f.exists() && !f.isDirectory(); 8 | } 9 | 10 | public static boolean isType(File f, String... types) { 11 | for (String type : types) { 12 | if (f.getName().endsWith(type)) { 13 | return true; 14 | } 15 | } 16 | return false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/ImageUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.FontMetrics; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.image.BufferedImage; 9 | 10 | public class ImageUtils { 11 | private static final String watermark = "Created with JByteMod"; 12 | 13 | public static BufferedImage watermark(BufferedImage old) { 14 | BufferedImage copy = copyImage(old); 15 | Graphics2D g2d = copy.createGraphics(); 16 | g2d.setPaint(Color.black); 17 | g2d.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); 18 | FontMetrics fm = g2d.getFontMetrics(); 19 | int x = copy.getWidth() - fm.stringWidth(watermark) - 5; 20 | int y = fm.getHeight(); 21 | g2d.drawString(watermark, x, y); 22 | g2d.dispose(); 23 | return copy; 24 | } 25 | 26 | private static BufferedImage copyImage(BufferedImage source) { 27 | BufferedImage b = new BufferedImage(source.getWidth() + 60, source.getHeight() + 60, source.getType()); 28 | Graphics g = b.createGraphics(); 29 | g.setColor(Color.WHITE); 30 | g.fillRect(0, 0, source.getWidth() + 60, source.getHeight() + 60); 31 | g.setColor(Color.BLACK); 32 | g.drawImage(source, 30, 30, null); 33 | g.dispose(); 34 | return b; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/TextUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils; 2 | 3 | public class TextUtils { 4 | 5 | public static String toHtml(String str) { 6 | return "" + toBlack(str); 7 | } 8 | 9 | public static String toBlack(String str) { 10 | return addTag(str, "font color=#000000"); 11 | } 12 | 13 | public static String addTag(String str, String tag) { 14 | return "<" + tag + ">" + str + ""; 15 | } 16 | 17 | public static String toLight(String str) { 18 | return addTag(str, "font color=#999999"); 19 | } 20 | 21 | public static String toBold(String str) { 22 | return addTag(str, "b"); 23 | } 24 | 25 | public static String escape(String str) { 26 | return str.replace("&", "&").replace("<", "<").replace(">", ">"); 27 | } 28 | 29 | public static String toItalics(String str) { 30 | return addTag(str, "i"); 31 | } 32 | 33 | public static String max(String string, int i) { 34 | if (string.length() > i) { 35 | return string.substring(0, i) + "..."; 36 | } 37 | return string; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/asm/FrameGen.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.asm; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import javax.swing.JOptionPane; 7 | 8 | import org.objectweb.asm.ClassWriter; 9 | import org.objectweb.asm.tree.ClassNode; 10 | 11 | import me.grax.jbytemod.JByteMod; 12 | import me.grax.jbytemod.utils.ErrorDisplay; 13 | import me.lpk.util.ASMUtils; 14 | import me.lpk.util.JarUtils; 15 | 16 | public class FrameGen extends Thread { 17 | 18 | private static Map libraries; 19 | 20 | public static void regenerateFrames(JByteMod jbm, ClassNode cn) { 21 | if (libraries == null && JByteMod.ops.get("use_rt").getBoolean()) { 22 | if (JOptionPane.showConfirmDialog(null, JByteMod.res.getResource("load_rt")) == JOptionPane.OK_OPTION) { 23 | try { 24 | libraries = JarUtils.loadRT(); 25 | } catch (IOException e) { 26 | new ErrorDisplay(e); 27 | } 28 | if (libraries == null) { 29 | return; 30 | } 31 | } else { 32 | return; 33 | } 34 | } 35 | ClassWriter cw = new LibClassWriter(ClassWriter.COMPUTE_FRAMES, jbm.getFile().getClasses(), libraries); 36 | try { 37 | cn.accept(cw); 38 | ClassNode node2 = ASMUtils.getNode(cw.toByteArray()); 39 | cn.methods.clear(); 40 | cn.methods.addAll(node2.methods); 41 | JByteMod.LOGGER.log("Successfully regenerated frames at class " + cn.name); 42 | } catch (Exception e) { 43 | e.printStackTrace(); 44 | return; 45 | } 46 | } 47 | 48 | @Override 49 | public void run() { 50 | try { 51 | libraries = JarUtils.loadRT(); 52 | JByteMod.LOGGER.log("Successfully loaded RT.jar"); 53 | } catch (IOException e) { 54 | new ErrorDisplay(e); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/asm/Loader.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.asm; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import me.grax.jbytemod.JByteMod; 10 | import me.lpk.util.ASMUtils; 11 | 12 | public class Loader { 13 | public static ClassNode classToNode(String type) throws IOException { 14 | return ASMUtils.getNode(classToBytes(type)); 15 | } 16 | 17 | public static byte[] classToBytes(String type) throws IOException { 18 | if (type == null) { 19 | return null; 20 | } 21 | InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(type + ".class"); 22 | if (is == null) { 23 | JByteMod.LOGGER.err(type + " not in classpath"); 24 | return null; 25 | } 26 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 27 | byte[] buffer = new byte[4096]; 28 | int n; 29 | while ((n = is.read(buffer)) > 0) { 30 | baos.write(buffer, 0, n); 31 | } 32 | return baos.toByteArray(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/asm/ParentUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.asm; 2 | 3 | import java.util.Map; 4 | 5 | import org.objectweb.asm.tree.ClassNode; 6 | 7 | public class ParentUtils { 8 | private Map classes; 9 | 10 | public ParentUtils(Map classes) { 11 | this.classes = classes; 12 | } 13 | 14 | public boolean isAssignableFrom(ClassNode cn, ClassNode cn2) { 15 | if (cn2.name.equals(cn.name)) { 16 | return true; 17 | } 18 | for (String itfn : cn2.interfaces) { 19 | ClassNode itf = classes.get(itfn); 20 | if (itf == null) 21 | continue; 22 | if (isAssignableFrom(cn, itf)) { 23 | return true; 24 | } 25 | } 26 | if (cn2.superName != null) { 27 | ClassNode sn = classes.get(cn2.superName); 28 | if (sn != null) 29 | if (isAssignableFrom(cn, sn)) { 30 | return true; 31 | } 32 | } 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/attach/InjectUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.attach; 2 | 3 | import java.io.File; 4 | import java.io.FileOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.io.OutputStream; 8 | import java.util.Enumeration; 9 | import java.util.zip.ZipEntry; 10 | import java.util.zip.ZipFile; 11 | import java.util.zip.ZipOutputStream; 12 | 13 | import me.grax.jbytemod.JByteMod; 14 | 15 | public class InjectUtils { 16 | public static void copyItself(File source, File dest) throws IOException { 17 | ZipFile war = new ZipFile(source); 18 | ZipOutputStream append = new ZipOutputStream(new FileOutputStream(dest)); 19 | Enumeration entries = war.entries(); 20 | while (entries.hasMoreElements()) { 21 | ZipEntry e = entries.nextElement(); 22 | if (!e.getName().equals("META-INF/MANIFEST.MF")) { 23 | append.putNextEntry(e); 24 | if (!e.isDirectory()) { 25 | copy(war.getInputStream(e), append); 26 | } 27 | append.closeEntry(); 28 | } 29 | } 30 | ZipEntry e = new ZipEntry("META-INF/MANIFEST.MF"); 31 | append.putNextEntry(e); 32 | append.write(("Manifest-Version: 1.0\nAgent-Class: " + JByteMod.class.getName() 33 | + "\nCan-Redefine-Classes: true\nCan-Retransform-Classes: true\nCan-Set-Native-Method-Prefix: false\n").getBytes()); 34 | append.closeEntry(); 35 | war.close(); 36 | append.close(); 37 | } 38 | 39 | private static final byte[] BUFFER = new byte[4096 * 1024]; 40 | 41 | public static void copy(InputStream input, OutputStream output) throws IOException { 42 | int bytesRead; 43 | while ((bytesRead = input.read(BUFFER)) != -1) { 44 | output.write(BUFFER, 0, bytesRead); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/gui/LookUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.gui; 2 | 3 | import javax.swing.UIManager; 4 | 5 | import com.alee.laf.WebLookAndFeel; 6 | 7 | import me.grax.jbytemod.JByteMod; 8 | import me.grax.jbytemod.utils.ThemeChanges; 9 | 10 | public class LookUtils { 11 | public static void setLAF() { 12 | try { 13 | JByteMod.LOGGER.log("Setting default Look and Feel"); 14 | if (JByteMod.ops.get("use_weblaf").getBoolean()) { 15 | WebLookAndFeel.install(); 16 | } else { 17 | if (!changeLAF("javax.swing.plaf.nimbus.NimbusLookAndFeel")) { 18 | JByteMod.LOGGER.err("Failed to set Nimbus Look and Feel, trying to use WebLaF"); 19 | WebLookAndFeel.install(); 20 | } 21 | } 22 | } catch (Throwable t) { 23 | t.printStackTrace(); 24 | JByteMod.LOGGER.err("Failed to set Look and Feel"); 25 | } 26 | } 27 | 28 | public static boolean changeLAF(String name) { 29 | try { 30 | JByteMod.LOGGER.log("Changing UI to " + name); 31 | UIManager.setLookAndFeel(name); 32 | UIManager.getLookAndFeel().uninitialize(); 33 | UIManager.setLookAndFeel(name); 34 | if (name.equals("javax.swing.plaf.nimbus.NimbusLookAndFeel")) { 35 | ThemeChanges.setDefaults(); 36 | } 37 | if (JByteMod.instance != null) { 38 | JByteMod.restartGUI(); 39 | } 40 | return true; 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/gui/SwingUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Component; 5 | import java.awt.event.ActionListener; 6 | 7 | import javax.swing.JButton; 8 | import javax.swing.JList; 9 | import javax.swing.JPanel; 10 | import javax.swing.plaf.ListUI; 11 | 12 | import com.alee.laf.list.WebListUI; 13 | 14 | public class SwingUtils { 15 | public static JPanel withButton(Component c, String text, ActionListener e) { 16 | JPanel jp = new JPanel(); 17 | jp.setLayout(new BorderLayout()); 18 | jp.add(c, BorderLayout.CENTER); 19 | JButton help = new JButton(text); 20 | help.addActionListener(e); 21 | jp.add(help, BorderLayout.EAST); 22 | return jp; 23 | } 24 | 25 | public static void disableSelection(JList jl) { 26 | ListUI ui = (ListUI) jl.getUI(); 27 | if (ui instanceof WebListUI) { 28 | WebListUI wlui = (WebListUI) ui; 29 | wlui.setHighlightRolloverCell(false); 30 | wlui.setDecorateSelection(false); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/list/LazyListModel.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.list; 2 | 3 | import java.util.ArrayList; 4 | 5 | import javax.swing.AbstractListModel; 6 | 7 | public class LazyListModel extends AbstractListModel { 8 | 9 | private ArrayList list; 10 | 11 | public LazyListModel() { 12 | this.list = new ArrayList(); 13 | } 14 | 15 | public void addElement(E e) { 16 | list.add(e); 17 | } 18 | 19 | @Override 20 | public int getSize() { 21 | return list.size(); 22 | } 23 | 24 | @Override 25 | protected void fireIntervalAdded(Object source, int index0, int index1) { 26 | } 27 | 28 | @Override 29 | public E getElementAt(int index) { 30 | return list.get(index); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/lpk/util/drop/IDropUser.java: -------------------------------------------------------------------------------- 1 | package me.lpk.util.drop; 2 | 3 | import java.io.File; 4 | 5 | public interface IDropUser { 6 | public void preLoadJars(int id); 7 | 8 | public void onJarLoad(int id, File input); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/lpk/util/drop/JarDropHandler.java: -------------------------------------------------------------------------------- 1 | package me.lpk.util.drop; 2 | 3 | import java.awt.datatransfer.DataFlavor; 4 | import java.awt.datatransfer.Transferable; 5 | import java.io.File; 6 | import java.util.List; 7 | 8 | import javax.swing.TransferHandler; 9 | 10 | public class JarDropHandler extends TransferHandler { 11 | private static final long serialVersionUID = 1232L; 12 | private final IDropUser user; 13 | private final int id; 14 | 15 | public JarDropHandler(IDropUser user, int id) { 16 | this.user = user; 17 | this.id = id; 18 | } 19 | 20 | @Override 21 | public boolean canImport(TransferHandler.TransferSupport info) { 22 | info.setShowDropLocation(false); 23 | return info.isDrop() && info.isDataFlavorSupported(DataFlavor.javaFileListFlavor); 24 | } 25 | 26 | @SuppressWarnings("unchecked") 27 | @Override 28 | public boolean importData(TransferHandler.TransferSupport info) { 29 | if (!info.isDrop()) 30 | return false; 31 | Transferable t = info.getTransferable(); 32 | List data = null; 33 | try { 34 | data = (List) t.getTransferData(DataFlavor.javaFileListFlavor); 35 | } catch (Exception e) { 36 | return false; 37 | } 38 | user.preLoadJars(id); 39 | for (File jar : data) { 40 | if (jar.getName().toLowerCase().endsWith(".jar")) { 41 | user.onJarLoad(id, jar); 42 | break; 43 | } 44 | } 45 | return true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/FullInstructionSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code; 17 | 18 | import org.jetbrains.java.decompiler.util.VBStyleCollection; 19 | 20 | public class FullInstructionSequence extends InstructionSequence { 21 | 22 | // ***************************************************************************** 23 | // constructors 24 | // ***************************************************************************** 25 | 26 | public FullInstructionSequence(VBStyleCollection collinstr, ExceptionTable extable) { 27 | super(collinstr); 28 | this.exceptionTable = extable; 29 | 30 | // translate raw exception handlers to instr 31 | for (ExceptionHandler handler : extable.getHandlers()) { 32 | handler.from_instr = this.getPointerByAbsOffset(handler.from); 33 | handler.to_instr = this.getPointerByAbsOffset(handler.to); 34 | handler.handler_instr = this.getPointerByAbsOffset(handler.handler); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/IfInstruction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | /* 22 | * opc_ifeq, opc_ifne, opc_iflt, opc_ifge, opc_ifgt, opc_ifle, opc_if_icmpeq, opc_if_icmpne, opc_if_icmplt, 23 | * opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_acmpeq, opc_if_acmpne, opc_ifnull, opc_ifnonnull 24 | */ 25 | 26 | public class IfInstruction extends JumpInstruction { 27 | 28 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 29 | out.writeByte(opcode); 30 | out.writeShort(getOperand(0)); 31 | } 32 | 33 | public int length() { 34 | return 3; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/JumpInstruction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code; 17 | 18 | /* 19 | * opc_ifeq, opc_ifne, opc_iflt, opc_ifge, opc_ifgt, opc_ifle, opc_if_icmpeq, opc_if_icmpne, opc_if_icmplt, 20 | * opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_acmpeq, opc_if_acmpne, opc_ifnull, opc_ifnonnull 21 | * opc_goto, opc_jsr, opc_goto_w, opc_jsr_w 22 | */ 23 | 24 | public class JumpInstruction extends Instruction { 25 | 26 | public int destination; 27 | 28 | public JumpInstruction() { 29 | } 30 | 31 | public void initInstruction(InstructionSequence seq) { 32 | destination = seq.getPointerByRelOffset(this.getOperand(0)); 33 | } 34 | 35 | public JumpInstruction clone() { 36 | JumpInstruction newinstr = (JumpInstruction) super.clone(); 37 | 38 | newinstr.destination = destination; 39 | return newinstr; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/SimpleInstructionSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code; 17 | 18 | import org.jetbrains.java.decompiler.util.VBStyleCollection; 19 | 20 | public class SimpleInstructionSequence extends InstructionSequence { 21 | 22 | public SimpleInstructionSequence() { 23 | } 24 | 25 | public SimpleInstructionSequence(VBStyleCollection collinstr) { 26 | super(collinstr); 27 | } 28 | 29 | public SimpleInstructionSequence clone() { 30 | SimpleInstructionSequence newseq = new SimpleInstructionSequence(collinstr.clone()); 31 | newseq.setPointer(this.getPointer()); 32 | 33 | return newseq; 34 | } 35 | 36 | public void removeInstruction(int index) { 37 | collinstr.remove(index); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/ALOAD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class ALOAD extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_aload); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | if (wide) { 48 | return 4; 49 | } else { 50 | return 2; 51 | } 52 | } else { 53 | return 1; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/ANEWARRAY.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class ANEWARRAY extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_anewarray); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/ASTORE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class ASTORE extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_astore); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | if (wide) { 48 | return 4; 49 | } else { 50 | return 2; 51 | } 52 | } else { 53 | return 1; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/BIPUSH.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class BIPUSH extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_iconst_m1, opc_iconst_0, opc_iconst_1, opc_iconst_2, opc_iconst_3, opc_iconst_4, 26 | opc_iconst_5 }; 27 | 28 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 29 | int value = getOperand(0); 30 | if (value < -1 || value > 5) { 31 | out.writeByte(opc_bipush); 32 | out.writeByte(value); 33 | } else { 34 | out.writeByte(opcodes[value + 1]); 35 | } 36 | } 37 | 38 | public int length() { 39 | int value = getOperand(0); 40 | if (value < -1 || value > 5) { 41 | return 2; 42 | } else { 43 | return 1; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/CHECKCAST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class CHECKCAST extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_checkcast); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/DLOAD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class DLOAD extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_dload); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | if (wide) { 48 | return 4; 49 | } else { 50 | return 2; 51 | } 52 | } else { 53 | return 1; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/DSTORE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class DSTORE extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_dstore); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | if (wide) { 48 | return 4; 49 | } else { 50 | return 2; 51 | } 52 | } else { 53 | return 1; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/FLOAD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class FLOAD extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_fload); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | if (wide) { 48 | return 4; 49 | } else { 50 | return 2; 51 | } 52 | } else { 53 | return 1; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/FSTORE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class FSTORE extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_fstore); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | if (wide) { 48 | return 4; 49 | } else { 50 | return 2; 51 | } 52 | } else { 53 | return 1; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/GETFIELD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class GETFIELD extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_getfield); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/GETSTATIC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class GETSTATIC extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_getstatic); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/GOTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.JumpInstruction; 22 | 23 | public class GOTO extends JumpInstruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | int operand = getOperand(0); 27 | if (operand < -32768 || operand > 32767) { 28 | out.writeByte(opc_goto_w); 29 | out.writeInt(operand); 30 | } else { 31 | out.writeByte(opc_goto); 32 | out.writeShort(operand); 33 | } 34 | } 35 | 36 | public int length() { 37 | int operand = getOperand(0); 38 | if (operand < -32768 || operand > 32767) { 39 | return 5; 40 | } else { 41 | return 3; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/GOTO_W.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.JumpInstruction; 22 | 23 | public class GOTO_W extends JumpInstruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_goto_w); 27 | out.writeInt(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 5; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/IINC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class IINC extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | if (wide) { 27 | out.writeByte(opc_wide); 28 | } 29 | out.writeByte(opc_iinc); 30 | if (wide) { 31 | out.writeShort(getOperand(0)); 32 | out.writeShort(getOperand(1)); 33 | } else { 34 | out.writeByte(getOperand(0)); 35 | out.writeByte(getOperand(1)); 36 | } 37 | } 38 | 39 | public int length() { 40 | return wide ? 6 : 3; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/ILOAD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class ILOAD extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_iload); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | return wide ? 4 : 2; 48 | } else { 49 | return 1; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/INSTANCEOF.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class INSTANCEOF extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_instanceof); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/INVOKEDYNAMIC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class INVOKEDYNAMIC extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_invokedynamic); 27 | out.writeShort(getOperand(0)); 28 | out.writeByte(0); 29 | out.writeByte(0); 30 | } 31 | 32 | public int length() { 33 | return 5; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/INVOKEINTERFACE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class INVOKEINTERFACE extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_invokeinterface); 27 | out.writeShort(getOperand(0)); 28 | out.writeByte(getOperand(1)); 29 | out.writeByte(0); 30 | } 31 | 32 | public int length() { 33 | return 5; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/INVOKESPECIAL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class INVOKESPECIAL extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_invokespecial); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/INVOKESTATIC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class INVOKESTATIC extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_invokestatic); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/INVOKEVIRTUAL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class INVOKEVIRTUAL extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_invokevirtual); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/ISTORE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class ISTORE extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_istore); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | return wide ? 4 : 2; 48 | } else { 49 | return 1; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/JSR.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.JumpInstruction; 22 | 23 | public class JSR extends JumpInstruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | int operand = getOperand(0); 27 | if (operand < -32768 || operand > 32767) { 28 | out.writeByte(opc_jsr_w); 29 | out.writeInt(operand); 30 | } else { 31 | out.writeByte(opc_jsr); 32 | out.writeShort(operand); 33 | } 34 | } 35 | 36 | public int length() { 37 | int operand = getOperand(0); 38 | if (operand < -32768 || operand > 32767) { 39 | return 5; 40 | } else { 41 | return 3; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/JSR_W.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.JumpInstruction; 22 | 23 | public class JSR_W extends JumpInstruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_jsr_w); 27 | out.writeInt(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 5; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/LDC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class LDC extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_ldc); 27 | out.writeByte(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 2; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/LDC2_W.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class LDC2_W extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_ldc2_w); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/LDC_W.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class LDC_W extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_ldc_w); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/LLOAD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class LLOAD extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_lload); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | return wide ? 4 : 2; 48 | } else { 49 | return 1; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/LOOKUPSWITCH.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.SwitchInstruction; 22 | 23 | public class LOOKUPSWITCH extends SwitchInstruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | 27 | out.writeByte(opc_lookupswitch); 28 | 29 | int padding = 3 - (offset % 4); 30 | for (int i = 0; i < padding; i++) { 31 | out.writeByte(0); 32 | } 33 | 34 | for (int i = 0; i < operandsCount(); i++) { 35 | out.writeInt(getOperand(i)); 36 | } 37 | } 38 | 39 | public int length() { 40 | return 1 + operandsCount() * 4; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/LSTORE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class LSTORE extends Instruction { 24 | 25 | private static final int[] opcodes = new int[] { opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3 }; 26 | 27 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 28 | int index = getOperand(0); 29 | if (index > 3) { 30 | if (wide) { 31 | out.writeByte(opc_wide); 32 | } 33 | out.writeByte(opc_lstore); 34 | if (wide) { 35 | out.writeShort(index); 36 | } else { 37 | out.writeByte(index); 38 | } 39 | } else { 40 | out.writeByte(opcodes[index]); 41 | } 42 | } 43 | 44 | public int length() { 45 | int index = getOperand(0); 46 | if (index > 3) { 47 | return wide ? 4 : 2; 48 | } else { 49 | return 1; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/MULTIANEWARRAY.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class MULTIANEWARRAY extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_multianewarray); 27 | out.writeShort(getOperand(0)); 28 | out.writeByte(getOperand(1)); 29 | } 30 | 31 | public int length() { 32 | return 4; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/NEW.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class NEW extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_new); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/NEWARRAY.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class NEWARRAY extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_newarray); 27 | out.writeByte(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 2; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/PUTFIELD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class PUTFIELD extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_putfield); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/PUTSTATIC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class PUTSTATIC extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_putstatic); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/RET.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class RET extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | if (wide) { 27 | out.writeByte(opc_wide); 28 | } 29 | out.writeByte(opc_ret); 30 | if (wide) { 31 | out.writeShort(getOperand(0)); 32 | } else { 33 | out.writeByte(getOperand(0)); 34 | } 35 | } 36 | 37 | public int length() { 38 | return wide ? 4 : 2; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/SIPUSH.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.Instruction; 22 | 23 | public class SIPUSH extends Instruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | out.writeByte(opc_sipush); 27 | out.writeShort(getOperand(0)); 28 | } 29 | 30 | public int length() { 31 | return 3; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/optinstructions/TABLESWITCH.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.code.optinstructions; 17 | 18 | import java.io.DataOutputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.code.SwitchInstruction; 22 | 23 | public class TABLESWITCH extends SwitchInstruction { 24 | 25 | public void writeToStream(DataOutputStream out, int offset) throws IOException { 26 | 27 | out.writeByte(opc_tableswitch); 28 | 29 | int padding = 3 - (offset % 4); 30 | for (int i = 0; i < padding; i++) { 31 | out.writeByte(0); 32 | } 33 | 34 | for (int i = 0; i < operandsCount(); i++) { 35 | out.writeInt(getOperand(i)); 36 | } 37 | } 38 | 39 | public int length() { 40 | return 1 + operandsCount() * 4; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/collectors/CounterContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.collectors; 17 | 18 | public class CounterContainer { 19 | 20 | public static final int STATEMENT_COUNTER = 0; 21 | public static final int EXPRENT_COUNTER = 1; 22 | public static final int VAR_COUNTER = 2; 23 | 24 | private final int[] values = new int[] { 1, 1, 1 }; 25 | 26 | public void setCounter(int counter, int value) { 27 | values[counter] = value; 28 | } 29 | 30 | public int getCounter(int counter) { 31 | return values[counter]; 32 | } 33 | 34 | public int getCounterAndIncrement(int counter) { 35 | return values[counter]++; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.collectors; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | public class VarNamesCollector { 22 | 23 | private final Set usedNames = new HashSet<>(); 24 | 25 | public VarNamesCollector() { 26 | } 27 | 28 | public VarNamesCollector(Set setNames) { 29 | usedNames.addAll(setNames); 30 | } 31 | 32 | public void addName(String value) { 33 | usedNames.add(value); 34 | } 35 | 36 | public String getFreeName(int index) { 37 | return getFreeName("var" + index); 38 | } 39 | 40 | public String getFreeName(String proposition) { 41 | while (usedNames.contains(proposition)) { 42 | proposition += "x"; 43 | } 44 | usedNames.add(proposition); 45 | return proposition; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/decompiler/BaseDecompiler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.decompiler; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | import java.util.Map; 21 | 22 | import org.jetbrains.java.decompiler.main.Fernflower; 23 | import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider; 24 | import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger; 25 | import org.jetbrains.java.decompiler.main.extern.IResultSaver; 26 | 27 | public class BaseDecompiler { 28 | 29 | private final Fernflower fernflower; 30 | 31 | public BaseDecompiler(IBytecodeProvider provider, IResultSaver saver, Map options, IFernflowerLogger logger) { 32 | fernflower = new Fernflower(provider, saver, options, logger); 33 | } 34 | 35 | public void addSpace(File file, boolean isOwn) throws IOException { 36 | fernflower.getStructContext().addSpace(file, isOwn); 37 | } 38 | 39 | public void decompileContext() { 40 | try { 41 | fernflower.decompileContext(); 42 | } finally { 43 | fernflower.clearContext(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IBytecodeProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.extern; 17 | 18 | import java.io.IOException; 19 | 20 | public interface IBytecodeProvider { 21 | byte[] getBytecode(String externalPath, String internalPath) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IFernflowerLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.extern; 17 | 18 | public abstract class IFernflowerLogger { 19 | 20 | public enum Severity { 21 | TRACE("TRACE: "), INFO("INFO: "), WARN("WARN: "), ERROR("ERROR: "); 22 | 23 | public final String prefix; 24 | 25 | Severity(String prefix) { 26 | this.prefix = prefix; 27 | } 28 | } 29 | 30 | private Severity severity = Severity.INFO; 31 | 32 | public boolean accepts(Severity severity) { 33 | return severity.ordinal() >= this.severity.ordinal(); 34 | } 35 | 36 | public void setSeverity(Severity severity) { 37 | this.severity = severity; 38 | } 39 | 40 | public abstract void writeMessage(String message, Severity severity); 41 | 42 | public abstract void writeMessage(String message, Throwable t); 43 | 44 | public void startReadingClass(String className) { 45 | } 46 | 47 | public void endReadingClass() { 48 | } 49 | 50 | public void startClass(String className) { 51 | } 52 | 53 | public void endClass() { 54 | } 55 | 56 | public void startMethod(String methodName) { 57 | } 58 | 59 | public void endMethod() { 60 | } 61 | 62 | public void startWriteClass(String className) { 63 | } 64 | 65 | public void endWriteClass() { 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IIdentifierRenamer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.extern; 17 | 18 | public interface IIdentifierRenamer { 19 | 20 | enum Type { 21 | ELEMENT_CLASS, ELEMENT_FIELD, ELEMENT_METHOD 22 | } 23 | 24 | boolean toBeRenamed(Type elementType, String className, String element, String descriptor); 25 | 26 | String getNextClassName(String fullName, String shortName); 27 | 28 | String getNextFieldName(String className, String field, String descriptor); 29 | 30 | String getNextMethodName(String className, String method, String descriptor); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IResultSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.main.extern; 17 | 18 | import java.util.jar.Manifest; 19 | 20 | public interface IResultSaver { 21 | void saveFolder(String path); 22 | 23 | void copyFile(String source, String path, String entryName); 24 | 25 | void saveClassFile(String path, String qualifiedName, String entryName, String content, int[] mapping); 26 | 27 | void createArchive(String path, String archiveName, Manifest manifest); 28 | 29 | void saveDirEntry(String path, String archiveName, String entryName); 30 | 31 | void copyEntry(String source, String path, String archiveName, String entry); 32 | 33 | void saveClassEntry(String path, String archiveName, String qualifiedName, String entryName, String content); 34 | 35 | void closeArchive(String path, String archiveName); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/ClearStructHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler; 17 | 18 | import java.util.LinkedList; 19 | 20 | import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 21 | import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; 22 | 23 | public class ClearStructHelper { 24 | 25 | public static void clearStatements(RootStatement root) { 26 | 27 | LinkedList stack = new LinkedList<>(); 28 | stack.add(root); 29 | 30 | while (!stack.isEmpty()) { 31 | 32 | Statement stat = stack.removeFirst(); 33 | 34 | stat.clearTempInformation(); 35 | 36 | stack.addAll(stat.getStats()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/ExprentStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler; 17 | 18 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 19 | import org.jetbrains.java.decompiler.util.ListStack; 20 | 21 | public class ExprentStack extends ListStack { 22 | 23 | public ExprentStack() { 24 | } 25 | 26 | public ExprentStack(ListStack list) { 27 | super(list); 28 | pointer = list.getPointer(); 29 | } 30 | 31 | public Exprent push(Exprent item) { 32 | super.push(item); 33 | 34 | return item; 35 | } 36 | 37 | public Exprent pop() { 38 | 39 | return this.remove(--pointer); 40 | } 41 | 42 | public ExprentStack clone() { 43 | return new ExprentStack(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/PrimitiveExprsList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 22 | 23 | public class PrimitiveExprsList { 24 | 25 | private final List lstExprents = new ArrayList<>(); 26 | 27 | private ExprentStack stack = new ExprentStack(); 28 | 29 | public PrimitiveExprsList() { 30 | } 31 | 32 | public PrimitiveExprsList copyStack() { 33 | PrimitiveExprsList prlst = new PrimitiveExprsList(); 34 | prlst.setStack(stack.clone()); 35 | return prlst; 36 | } 37 | 38 | public List getLstExprents() { 39 | return lstExprents; 40 | } 41 | 42 | public ExprentStack getStack() { 43 | return stack; 44 | } 45 | 46 | public void setStack(ExprentStack stack) { 47 | this.stack = stack; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/decompose/IGraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler.decompose; 17 | 18 | import java.util.List; 19 | import java.util.Set; 20 | 21 | public interface IGraph { 22 | 23 | List getReversePostOrderList(); 24 | 25 | Set getRoots(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/decompose/IGraphNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler.decompose; 17 | 18 | import java.util.List; 19 | 20 | public interface IGraphNode { 21 | 22 | List getPredecessors(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/exps/AssertExprent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler.exps; 17 | 18 | import java.util.List; 19 | 20 | import org.jetbrains.java.decompiler.main.TextBuffer; 21 | import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; 22 | 23 | public class AssertExprent extends Exprent { 24 | 25 | private final List parameters; 26 | 27 | public AssertExprent(List parameters) { 28 | super(EXPRENT_ASSERT); 29 | this.parameters = parameters; 30 | } 31 | 32 | @Override 33 | public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { 34 | TextBuffer buffer = new TextBuffer(); 35 | 36 | buffer.append("assert "); 37 | 38 | tracer.addMapping(bytecode); 39 | 40 | if (parameters.get(0) == null) { 41 | buffer.append("false"); 42 | } else { 43 | buffer.append(parameters.get(0).toJava(indent, tracer)); 44 | } 45 | 46 | if (parameters.size() > 1) { 47 | buffer.append(" : "); 48 | buffer.append(parameters.get(1).toJava(indent, tracer)); 49 | } 50 | 51 | return buffer; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/stats/DummyExitStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler.stats; 17 | 18 | import java.util.Collection; 19 | import java.util.HashSet; 20 | import java.util.Set; 21 | 22 | /** 23 | * @author egor 24 | */ 25 | public class DummyExitStatement extends Statement { 26 | public Set bytecode = null; // offsets of bytecode instructions mapped to dummy exit 27 | 28 | public DummyExitStatement() { 29 | type = Statement.TYPE_DUMMYEXIT; 30 | } 31 | 32 | public void addBytecodeOffsets(Collection bytecodeOffsets) { 33 | if (bytecodeOffsets != null && !bytecodeOffsets.isEmpty()) { 34 | if (bytecode == null) { 35 | bytecode = new HashSet<>(bytecodeOffsets); 36 | } else { 37 | bytecode.addAll(bytecodeOffsets); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/stats/RootStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler.stats; 17 | 18 | import org.jetbrains.java.decompiler.main.TextBuffer; 19 | import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; 20 | import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; 21 | 22 | public class RootStatement extends Statement { 23 | 24 | private DummyExitStatement dummyExit; 25 | 26 | public RootStatement(Statement head, DummyExitStatement dummyExit) { 27 | 28 | type = Statement.TYPE_ROOT; 29 | 30 | first = head; 31 | this.dummyExit = dummyExit; 32 | 33 | stats.addWithKey(first, first.id); 34 | first.setParent(this); 35 | } 36 | 37 | public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { 38 | return ExprProcessor.listToJava(varDefinitions, indent, tracer).append(first.toJava(indent, tracer)); 39 | } 40 | 41 | public DummyExitStatement getDummyExit() { 42 | return dummyExit; 43 | } 44 | 45 | public void setDummyExit(DummyExitStatement dummyExit) { 46 | this.dummyExit = dummyExit; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionEdge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.decompiler.vars; 17 | 18 | public class VarVersionEdge { // FIXME: can be removed? 19 | 20 | public static final int EDGE_GENERAL = 0; 21 | public static final int EDGE_PHANTOM = 1; 22 | 23 | public final int type; 24 | 25 | public final VarVersionNode source; 26 | 27 | public final VarVersionNode dest; 28 | 29 | private final int hashCode; 30 | 31 | public VarVersionEdge(int type, VarVersionNode source, VarVersionNode dest) { 32 | this.type = type; 33 | this.source = source; 34 | this.dest = dest; 35 | this.hashCode = source.hashCode() ^ dest.hashCode() + type; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object o) { 40 | if (o == this) 41 | return true; 42 | if (o == null || !(o instanceof VarVersionEdge)) 43 | return false; 44 | 45 | VarVersionEdge edge = (VarVersionEdge) o; 46 | return type == edge.type && source == edge.source && dest == edge.dest; 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | return hashCode; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return source.toString() + " ->" + type + "-> " + dest.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/renamer/ClassWrapperNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.renamer; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.jetbrains.java.decompiler.struct.StructClass; 22 | 23 | public class ClassWrapperNode { 24 | 25 | private final StructClass classStruct; 26 | 27 | private ClassWrapperNode superclass; 28 | 29 | private final List subclasses = new ArrayList<>(); 30 | 31 | public ClassWrapperNode(StructClass cl) { 32 | this.classStruct = cl; 33 | } 34 | 35 | public void addSubclass(ClassWrapperNode node) { 36 | node.setSuperclass(this); 37 | subclasses.add(node); 38 | } 39 | 40 | public StructClass getClassStruct() { 41 | return classStruct; 42 | } 43 | 44 | public List getSubclasses() { 45 | return subclasses; 46 | } 47 | 48 | public ClassWrapperNode getSuperclass() { 49 | return superclass; 50 | } 51 | 52 | public void setSuperclass(ClassWrapperNode superclass) { 53 | this.superclass = superclass; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/renamer/PoolInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.modules.renamer; 17 | 18 | import java.util.HashMap; 19 | 20 | import org.jetbrains.java.decompiler.main.extern.IIdentifierRenamer; 21 | 22 | public class PoolInterceptor { 23 | 24 | private final IIdentifierRenamer helper; 25 | 26 | private final HashMap mapOldToNewNames = new HashMap<>(); 27 | 28 | private final HashMap mapNewToOldNames = new HashMap<>(); 29 | 30 | public PoolInterceptor(IIdentifierRenamer helper) { 31 | this.helper = helper; 32 | } 33 | 34 | public void addName(String oldName, String newName) { 35 | mapOldToNewNames.put(oldName, newName); 36 | mapNewToOldNames.put(newName, oldName); 37 | } 38 | 39 | public String getName(String oldName) { 40 | return mapOldToNewNames.get(oldName); 41 | } 42 | 43 | public String getOldName(String newName) { 44 | return mapNewToOldNames.get(newName); 45 | } 46 | 47 | public IIdentifierRenamer getHelper() { 48 | return helper; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/IDecompiledData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct; 17 | 18 | public interface IDecompiledData { 19 | 20 | String getClassEntryName(StructClass cl, String entryname); 21 | 22 | String getClassContent(StructClass cl); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.IOException; 19 | 20 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 21 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 22 | 23 | public class StructAnnDefaultAttribute extends StructGeneralAttribute { 24 | 25 | private Exprent defaultValue; 26 | 27 | @Override 28 | public void initContent(ConstantPool pool) throws IOException { 29 | defaultValue = StructAnnotationAttribute.parseAnnotationElement(stream(), pool); 30 | } 31 | 32 | public Exprent getDefaultValue() { 33 | return defaultValue; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.DataInputStream; 19 | import java.io.IOException; 20 | import java.util.ArrayList; 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import org.jetbrains.java.decompiler.modules.decompiler.exps.AnnotationExprent; 25 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 26 | 27 | public class StructAnnotationParameterAttribute extends StructGeneralAttribute { 28 | 29 | private List> paramAnnotations; 30 | 31 | @Override 32 | public void initContent(ConstantPool pool) throws IOException { 33 | DataInputStream data = stream(); 34 | 35 | int len = data.readUnsignedByte(); 36 | if (len > 0) { 37 | paramAnnotations = new ArrayList<>(len); 38 | for (int i = 0; i < len; i++) { 39 | List annotations = StructAnnotationAttribute.parseAnnotations(pool, data); 40 | paramAnnotations.add(annotations); 41 | } 42 | } else { 43 | paramAnnotations = Collections.emptyList(); 44 | } 45 | } 46 | 47 | public List> getParamAnnotations() { 48 | return paramAnnotations; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.IOException; 19 | 20 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 21 | 22 | public class StructConstantValueAttribute extends StructGeneralAttribute { 23 | 24 | private int index; 25 | 26 | @Override 27 | public void initContent(ConstantPool pool) throws IOException { 28 | index = stream().readUnsignedShort(); 29 | } 30 | 31 | public int getIndex() { 32 | return index; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.DataInputStream; 19 | import java.io.IOException; 20 | 21 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 22 | import org.jetbrains.java.decompiler.struct.consts.LinkConstant; 23 | 24 | public class StructEnclosingMethodAttribute extends StructGeneralAttribute { 25 | 26 | private String className; 27 | private String methodName; 28 | private String methodDescriptor; 29 | 30 | @Override 31 | public void initContent(ConstantPool pool) throws IOException { 32 | DataInputStream data = stream(); 33 | int classIndex = data.readUnsignedShort(); 34 | int methodIndex = data.readUnsignedShort(); 35 | 36 | className = pool.getPrimitiveConstant(classIndex).getString(); 37 | if (methodIndex != 0) { 38 | LinkConstant lk = pool.getLinkConstant(methodIndex); 39 | methodName = lk.elementname; 40 | methodDescriptor = lk.descriptor; 41 | } 42 | } 43 | 44 | public String getClassName() { 45 | return className; 46 | } 47 | 48 | public String getMethodDescriptor() { 49 | return methodDescriptor; 50 | } 51 | 52 | public String getMethodName() { 53 | return methodName; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.DataInputStream; 19 | import java.io.IOException; 20 | import java.util.ArrayList; 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 25 | 26 | public class StructExceptionsAttribute extends StructGeneralAttribute { 27 | 28 | private List throwsExceptions; 29 | 30 | @Override 31 | public void initContent(ConstantPool pool) throws IOException { 32 | DataInputStream data = stream(); 33 | int len = data.readUnsignedShort(); 34 | if (len > 0) { 35 | throwsExceptions = new ArrayList<>(len); 36 | for (int i = 0; i < len; i++) { 37 | throwsExceptions.add(data.readUnsignedShort()); 38 | } 39 | } else { 40 | throwsExceptions = Collections.emptyList(); 41 | } 42 | } 43 | 44 | public String getExcClassname(int index, ConstantPool pool) { 45 | return pool.getPrimitiveConstant(throwsExceptions.get(index).intValue()).getString(); 46 | } 47 | 48 | public List getThrowsExceptions() { 49 | return throwsExceptions; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.IOException; 19 | 20 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 21 | 22 | public class StructGenericSignatureAttribute extends StructGeneralAttribute { 23 | 24 | private String signature; 25 | 26 | @Override 27 | public void initContent(ConstantPool pool) throws IOException { 28 | int index = stream().readUnsignedShort(); 29 | signature = pool.getPrimitiveConstant(index).getString(); 30 | } 31 | 32 | public String getSignature() { 33 | return signature; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructSourceFileAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.attr; 17 | 18 | import java.io.IOException; 19 | 20 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 21 | 22 | public class StructSourceFileAttribute extends StructGeneralAttribute { 23 | 24 | private String fileName; 25 | 26 | @Override 27 | public void initContent(ConstantPool pool) throws IOException { 28 | int index = stream().readUnsignedShort(); 29 | fileName = pool.getPrimitiveConstant(index).getString(); 30 | } 31 | 32 | public String getFileName() { 33 | return fileName; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/consts/VariableTypeEnum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.consts; 17 | 18 | public interface VariableTypeEnum { 19 | 20 | int BOOLEAN = 1; 21 | int BYTE = 2; 22 | int CHAR = 3; 23 | int SHORT = 4; 24 | int INT = 5; 25 | int FLOAT = 6; 26 | int LONG = 7; 27 | int DOUBLE = 8; 28 | int RETURN_ADDRESS = 9; 29 | int REFERENCE = 10; 30 | int INSTANCE_UNINITIALIZED = 11; 31 | int VALUE_UNKNOWN = 12; 32 | int VOID = 13; 33 | 34 | Integer BOOLEAN_OBJ = new Integer(BOOLEAN); 35 | Integer BYTE_OBJ = new Integer(BYTE); 36 | Integer CHAR_OBJ = new Integer(CHAR); 37 | Integer SHORT_OBJ = new Integer(SHORT); 38 | Integer INT_OBJ = new Integer(INT); 39 | Integer FLOAT_OBJ = new Integer(FLOAT); 40 | Integer LONG_OBJ = new Integer(LONG); 41 | Integer DOUBLE_OBJ = new Integer(DOUBLE); 42 | Integer RETURN_ADDRESS_OBJ = new Integer(RETURN_ADDRESS); 43 | Integer REFERENCE_OBJ = new Integer(REFERENCE); 44 | Integer INSTANCE_UNINITIALIZED_OBJ = new Integer(INSTANCE_UNINITIALIZED); 45 | Integer VALUE_UNKNOWN_OBJ = new Integer(VALUE_UNKNOWN); 46 | Integer VOID_OBJ = new Integer(VOID); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/NewClassNameBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.gen; 17 | 18 | public interface NewClassNameBuilder { 19 | String buildNewClassname(String className); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/generics/GenericClassDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.gen.generics; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class GenericClassDescriptor { 22 | 23 | public GenericType superclass; 24 | 25 | public final List superinterfaces = new ArrayList<>(); 26 | 27 | public final List fparameters = new ArrayList<>(); 28 | 29 | public final List> fbounds = new ArrayList<>(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/generics/GenericFieldDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.gen.generics; 17 | 18 | public class GenericFieldDescriptor { 19 | 20 | public GenericType type; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/generics/GenericMethodDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.gen.generics; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class GenericMethodDescriptor { 22 | 23 | public final List fparameters = new ArrayList<>(); 24 | 25 | public final List> fbounds = new ArrayList<>(); 26 | 27 | public final List params = new ArrayList<>(); 28 | 29 | public GenericType ret; 30 | 31 | public final List exceptions = new ArrayList<>(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/match/IMatchable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.struct.match; 17 | 18 | public interface IMatchable { 19 | 20 | enum MatchProperties { 21 | STATEMENT_TYPE, STATEMENT_RET, STATEMENT_STATSIZE, STATEMENT_EXPRSIZE, STATEMENT_POSITION, STATEMENT_IFTYPE, 22 | 23 | EXPRENT_TYPE, EXPRENT_RET, EXPRENT_POSITION, EXPRENT_FUNCTYPE, EXPRENT_EXITTYPE, EXPRENT_CONSTTYPE, EXPRENT_CONSTVALUE, EXPRENT_INVOCATION_CLASS, EXPRENT_INVOCATION_SIGNATURE, EXPRENT_INVOCATION_PARAMETER, EXPRENT_VAR_INDEX, EXPRENT_FIELD_NAME, 24 | } 25 | 26 | IMatchable findObject(MatchNode matchNode, int index); 27 | 28 | boolean match(MatchNode matchNode, MatchEngine engine); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/util/DataInputFullStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.jetbrains.java.decompiler.util; 17 | 18 | import java.io.ByteArrayInputStream; 19 | import java.io.DataInputStream; 20 | import java.io.IOException; 21 | 22 | public class DataInputFullStream extends DataInputStream { 23 | public DataInputFullStream(byte[] bytes) { 24 | super(new ByteArrayInputStream(bytes)); 25 | } 26 | 27 | public byte[] read(int n) throws IOException { 28 | return InterpreterUtil.readBytes(this, n); 29 | } 30 | 31 | public void discard(int n) throws IOException { 32 | InterpreterUtil.discardBytes(this, n); 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/org/objectweb/asm/optimizer/FieldConstantsCollector.java: -------------------------------------------------------------------------------- 1 | package org.objectweb.asm.optimizer; 2 | 3 | import org.objectweb.asm.AnnotationVisitor; 4 | import org.objectweb.asm.Attribute; 5 | import org.objectweb.asm.FieldVisitor; 6 | import org.objectweb.asm.Opcodes; 7 | import org.objectweb.asm.TypePath; 8 | 9 | /** 10 | * A {@link FieldVisitor} that collects the {@link Constant}s of the fields it 11 | * visits. 12 | * 13 | * @author Eric Bruneton 14 | */ 15 | public class FieldConstantsCollector extends FieldVisitor { 16 | 17 | private final ConstantPool cp; 18 | 19 | public FieldConstantsCollector(final FieldVisitor fv, final ConstantPool cp) { 20 | super(Opcodes.ASM5, fv); 21 | this.cp = cp; 22 | } 23 | 24 | @Override 25 | public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { 26 | cp.newUTF8(desc); 27 | if (visible) { 28 | cp.newUTF8("RuntimeVisibleAnnotations"); 29 | } else { 30 | cp.newUTF8("RuntimeInvisibleAnnotations"); 31 | } 32 | return new AnnotationConstantsCollector(fv.visitAnnotation(desc, visible), cp); 33 | } 34 | 35 | @Override 36 | public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { 37 | cp.newUTF8(desc); 38 | if (visible) { 39 | cp.newUTF8("RuntimeVisibleTypeAnnotations"); 40 | } else { 41 | cp.newUTF8("RuntimeInvisibleTypeAnnotations"); 42 | } 43 | return new AnnotationConstantsCollector(fv.visitAnnotation(desc, visible), cp); 44 | } 45 | 46 | @Override 47 | public void visitAttribute(final Attribute attr) { 48 | // can do nothing 49 | fv.visitAttribute(attr); 50 | } 51 | 52 | @Override 53 | public void visitEnd() { 54 | fv.visitEnd(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/objectweb/asm/signature/package.html: -------------------------------------------------------------------------------- 1 | 2 | 31 | 32 | Provides support for type signatures. 33 | 34 | @since ASM 2.0 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/resources/access/abstract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/access/abstract.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/access/final.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/native.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/access/native.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/access/static.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/synthetic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/access/synthetic.png -------------------------------------------------------------------------------- /src/main/resources/resources/classtype/enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/classtype/enum.png -------------------------------------------------------------------------------- /src/main/resources/resources/classtype/interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/classtype/interface.png -------------------------------------------------------------------------------- /src/main/resources/resources/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/file.png -------------------------------------------------------------------------------- /src/main/resources/resources/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/icon_close.png -------------------------------------------------------------------------------- /src/main/resources/resources/jar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/jar.png -------------------------------------------------------------------------------- /src/main/resources/resources/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/java.png -------------------------------------------------------------------------------- /src/main/resources/resources/krakatau.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/krakatau.zip -------------------------------------------------------------------------------- /src/main/resources/resources/method/methdef.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/method/methdef.png -------------------------------------------------------------------------------- /src/main/resources/resources/method/methpri.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/method/methpri.png -------------------------------------------------------------------------------- /src/main/resources/resources/method/methpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/method/methpro.png -------------------------------------------------------------------------------- /src/main/resources/resources/method/methpub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/method/methpub.png -------------------------------------------------------------------------------- /src/main/resources/resources/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/package.png -------------------------------------------------------------------------------- /src/main/resources/resources/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/search.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/toolbar/load.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/plug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/toolbar/plug.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/toolbar/refresh.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/toolbar/save.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/toolbar/search.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/toolbar/table.png -------------------------------------------------------------------------------- /src/main/resources/resources/txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/txt.png -------------------------------------------------------------------------------- /src/main/resources/resources/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraxCode/JByteMod-Beta/57e6f8ed761366c50b2cfd13b42a6f33197cef8c/src/main/resources/resources/warning.png --------------------------------------------------------------------------------