├── draft ├── howtorun.png └── howtorun_cmd.png ├── bytecode ├── Person.class ├── Test.class ├── BaseTest.class ├── Simple0.class ├── Simple1.class ├── GaussTest.class ├── ch07 │ ├── Vector.class │ ├── Vector2D.class │ ├── Vector3D.class │ ├── InvokeDemo.class │ ├── InvokeSpecialTest.class │ ├── InvokeVirtualTest.class │ └── InvokeInterfaceTest.class ├── gc │ ├── GCTest.class │ ├── GCTest0.class │ ├── GCTest1.class │ └── GCTest2.class ├── FibonacciTest.class ├── MyAnnotation.class ├── TestInterface.class ├── ch08 │ ├── Array1D.class │ ├── Array3D.class │ ├── ArrayDemo.class │ ├── StringTest.class │ ├── DoubleArray1D.class │ ├── BubbleSortTest.class │ ├── MultianewarrayDemo.class │ └── DoubleBubbleSortTest.class ├── AnnotationTest.class ├── ch09 │ ├── ArrayDemo.class │ └── StringBuilderTest.class ├── java │ ├── lang │ │ ├── Class.class │ │ ├── Math.class │ │ ├── Number.class │ │ ├── Object.class │ │ ├── String.class │ │ ├── System.class │ │ ├── Thread.class │ │ ├── Integer.class │ │ ├── String$1.class │ │ ├── System$1.class │ │ ├── System$2.class │ │ ├── Thread$1.class │ │ ├── StringBuilder.class │ │ ├── Thread$Caches.class │ │ ├── Thread$State.class │ │ ├── AbstractStringBuilder.class │ │ ├── Integer$IntegerCache.class │ │ ├── Thread$WeakClassKey.class │ │ ├── Thread$UncaughtExceptionHandler.class │ │ ├── Math$RandomNumberGeneratorHolder.class │ │ └── String$CaseInsensitiveComparator.class │ ├── util │ │ ├── Arrays.class │ │ ├── Arrays$ArrayList.class │ │ ├── Arrays$NaturalOrder.class │ │ └── Arrays$LegacyMergeSort.class │ └── io │ │ ├── OutputStream.class │ │ ├── PrintStream.class │ │ ├── FilterOutputStream.class │ │ └── ObjectStreamField.class ├── RuntimeAnnotationTest.class ├── classlink │ ├── T0ClassLink.class │ └── T1ClassLink.class ├── jvmgo │ └── book │ │ └── ch08 │ │ └── Array1D.class ├── nestedclass │ ├── AnonymousClass.class │ ├── T0NestedClass.class │ ├── T0NestedClass$1.class │ ├── T0NestedClass$1LocalClass.class │ ├── T0NestedClass$GenaralClass.class │ └── T0NestedClass$StaticClass.class └── com │ └── zvm │ └── javaclass │ └── integer │ ├── Son.class │ ├── Table.class │ ├── Table1.class │ └── Table1$1.class ├── src ├── main │ └── java │ │ └── com │ │ └── zvm │ │ ├── basestruct │ │ ├── U1.java │ │ ├── U2.java │ │ ├── U4.java │ │ └── TypeCode.java │ │ ├── classfile │ │ ├── attribute │ │ │ ├── AttributeBase.java │ │ │ ├── stackmaptable │ │ │ │ ├── StackMapFrame.java │ │ │ │ ├── verificationtypeinfo │ │ │ │ │ ├── VerificationTypeInfo.java │ │ │ │ │ ├── TopVariableInfo.java │ │ │ │ │ ├── NullVariableInfo.java │ │ │ │ │ ├── LongVariableInfo.java │ │ │ │ │ ├── FloatVariableInfo.java │ │ │ │ │ ├── DoubleVariableInfo.java │ │ │ │ │ ├── IntegerVariableInfo.java │ │ │ │ │ ├── UninitializedThisVariableInfo.java │ │ │ │ │ ├── ObjectVariableInfo.java │ │ │ │ │ └── UninitializedVariableInfo.java │ │ │ │ ├── SameFrame.java │ │ │ │ ├── ChopFrame.java │ │ │ │ ├── SameFrameExtended.java │ │ │ │ ├── SameLocals1StackItemFrame.java │ │ │ │ ├── AppendFrame.java │ │ │ │ ├── SameLocals1StackItemFrameExtended.java │ │ │ │ └── FullFrame.java │ │ │ ├── runtimeVisibleAnnotations │ │ │ │ ├── ElementValue.java │ │ │ │ ├── ElementValuePair.java │ │ │ │ ├── ValueAnnotation.java │ │ │ │ ├── ClassInfoIndex.java │ │ │ │ ├── ConstValueIndex.java │ │ │ │ ├── Annotation.java │ │ │ │ ├── ArrayValue.java │ │ │ │ └── EnumConstValue.java │ │ │ ├── RuntimeVisibleTypeAnnotations │ │ │ │ └── TypeAnnotation.java │ │ │ ├── MethodParameters │ │ │ │ └── Parameter.java │ │ │ ├── lineNumberTable │ │ │ │ └── LineNumber.java │ │ │ ├── code │ │ │ │ └── ExceptionTable.java │ │ │ ├── BootstrapMethod.java │ │ │ ├── DeprecatedAttribute.java │ │ │ ├── SyntheticAttribute.java │ │ │ ├── innerClasses │ │ │ │ └── Classes.java │ │ │ ├── LocalVariableTable │ │ │ │ └── LocalVariable.java │ │ │ ├── SignatureAttribute.java │ │ │ ├── SourceFileAttribute.java │ │ │ ├── LocalVariableTypeTable │ │ │ │ └── LocalVariableType.java │ │ │ ├── ConstantValueAttribute.java │ │ │ ├── EnclosingMethodAttribute.java │ │ │ ├── ExceptionsAttribute.java │ │ │ ├── SourceDebugExtensionAttribute.java │ │ │ ├── BootstrapMethodsAttribute.java │ │ │ ├── RuntimeVisibleParameterAnnotations │ │ │ │ └── ParameterAnnotation.java │ │ │ ├── InnerClassesAttribute.java │ │ │ ├── AnnotationDefaultAttribute.java │ │ │ ├── LineNumberTableAttribute.java │ │ │ ├── StackMapTableAttribute.java │ │ │ ├── LocalVariableTableAttribute.java │ │ │ ├── MethodParametersAttribute.java │ │ │ ├── RuntimeVisibleAnnotationsAttribute.java │ │ │ ├── RuntimeInvisibleAnnotationsAttribute.java │ │ │ ├── LocalVariableTypeTableAttribute.java │ │ │ ├── RuntimeInvisibleTypeAnnotationsAttribute.java │ │ │ ├── RuntimeVisibleTypeAnnotationsAttribute.java │ │ │ ├── RuntimeVisibleParameterAnnotationsAttribute.java │ │ │ ├── RuntimeInvisibleParameterAnnotationsAttribute.java │ │ │ └── CodeAttribute.java │ │ ├── constantpool │ │ │ ├── ConstantBase.java │ │ │ ├── ConstantFloat.java │ │ │ ├── ConstantClass.java │ │ │ ├── ConstantInteger.java │ │ │ ├── ConstantString.java │ │ │ ├── ConstantMethodtype.java │ │ │ ├── ConstantUtf8.java │ │ │ ├── ConstantDouble.java │ │ │ ├── ConstantLong.java │ │ │ ├── ConstantFieldref.java │ │ │ ├── ConstantMethodref.java │ │ │ ├── ConstantNameandtype.java │ │ │ ├── ConstantMethodhandle.java │ │ │ ├── ConstantInterfacemethodref.java │ │ │ └── ConstantInvokedynamic.java │ │ ├── CpInfo.java │ │ ├── ZvmClassLoader.java │ │ ├── MethodInfo.java │ │ └── FieldInfo.java │ │ ├── runtime │ │ ├── struct │ │ │ ├── JType.java │ │ │ ├── JChar.java │ │ │ ├── JByte.java │ │ │ ├── JInt.java │ │ │ ├── JLong.java │ │ │ ├── JFloat.java │ │ │ ├── JShort.java │ │ │ ├── JDouble.java │ │ │ ├── JArray.java │ │ │ ├── Slot.java │ │ │ └── JObject.java │ │ ├── StaticVars.java │ │ ├── LocalVars.java │ │ ├── ThreadStack.java │ │ ├── JavaFrame.java │ │ ├── JThread.java │ │ └── RunTimeEnv.java │ │ ├── interpreter │ │ ├── Descriptor.java │ │ └── Ref.java │ │ ├── jnative │ │ ├── NativeMethod.java │ │ └── NativeConstant.java │ │ ├── instruction │ │ ├── controltransfer │ │ │ ├── Ifnull.java │ │ │ ├── If_Acmpeq.java │ │ │ ├── Jsr.java │ │ │ ├── Jsr_W.java │ │ │ ├── Ret.java │ │ │ ├── Goto_W.java │ │ │ ├── LookupSwitch.java │ │ │ ├── TableSwitch.java │ │ │ ├── If_Acmpne.java │ │ │ └── Goto_.java │ │ ├── Instruction.java │ │ ├── oprandstack │ │ │ ├── Pop.java │ │ │ ├── Swap.java │ │ │ ├── Dup2.java │ │ │ ├── Pop2.java │ │ │ ├── Dup2_X1.java │ │ │ ├── Dup2_X2.java │ │ │ ├── Dup_X1.java │ │ │ ├── Dup_X2.java │ │ │ └── Dup.java │ │ ├── arithmetic │ │ │ ├── arithmetic │ │ │ │ ├── Irem.java │ │ │ │ ├── Lmul.java │ │ │ │ ├── Ddiv.java │ │ │ │ ├── Drem.java │ │ │ │ ├── Fdiv.java │ │ │ │ ├── Fmul.java │ │ │ │ ├── Frem.java │ │ │ │ ├── Idiv.java │ │ │ │ ├── Ldiv.java │ │ │ │ ├── Lrem.java │ │ │ │ ├── Iadd.java │ │ │ │ ├── Imul.java │ │ │ │ ├── Isub.java │ │ │ │ ├── Ladd.java │ │ │ │ ├── Lsub.java │ │ │ │ ├── Dmul.java │ │ │ │ ├── Fadd.java │ │ │ │ ├── Fsub.java │ │ │ │ ├── Dsub.java │ │ │ │ └── Dadd.java │ │ │ ├── bitwise │ │ │ │ ├── Ior.java │ │ │ │ ├── Lor.java │ │ │ │ ├── Dneg.java │ │ │ │ ├── Fneg.java │ │ │ │ ├── Ishl.java │ │ │ │ ├── Ishr.java │ │ │ │ ├── Iushr.java │ │ │ │ ├── Ixor.java │ │ │ │ ├── Lneg.java │ │ │ │ ├── Lshl.java │ │ │ │ ├── Lshr.java │ │ │ │ ├── Lushr.java │ │ │ │ ├── Lxor.java │ │ │ │ └── Ineg.java │ │ │ └── logic │ │ │ │ ├── Iand.java │ │ │ │ └── Land.java │ │ ├── loadandstore │ │ │ ├── constant │ │ │ │ ├── Nop.java │ │ │ │ ├── Iconst_0.java │ │ │ │ ├── Iconst_1.java │ │ │ │ ├── Iconst_2.java │ │ │ │ ├── Iconst_3.java │ │ │ │ ├── Iconst_4.java │ │ │ │ ├── Iconst_5.java │ │ │ │ ├── Dconst_0.java │ │ │ │ ├── Dconst_1.java │ │ │ │ ├── Fconst_0.java │ │ │ │ ├── Fconst_1.java │ │ │ │ ├── Fconst_2.java │ │ │ │ ├── Iconst_M1.java │ │ │ │ ├── Lconst_0.java │ │ │ │ ├── Lconst_1.java │ │ │ │ ├── Aconst_null.java │ │ │ │ ├── Bipush.java │ │ │ │ └── Sipush.java │ │ │ ├── Wide.java │ │ │ ├── load │ │ │ │ ├── Baload.java │ │ │ │ ├── Caload.java │ │ │ │ ├── Saload.java │ │ │ │ ├── Iload_0.java │ │ │ │ ├── Iload_1.java │ │ │ │ ├── Iload_2.java │ │ │ │ ├── Iload_3.java │ │ │ │ ├── Fload_0.java │ │ │ │ ├── Fload_1.java │ │ │ │ ├── Fload_2.java │ │ │ │ ├── Fload_3.java │ │ │ │ ├── Dload_0.java │ │ │ │ ├── Dload_1.java │ │ │ │ ├── Dload_2.java │ │ │ │ ├── Dload_3.java │ │ │ │ ├── Lload_0.java │ │ │ │ ├── Lload_1.java │ │ │ │ ├── Lload_2.java │ │ │ │ ├── Lload_3.java │ │ │ │ ├── Aload_1.java │ │ │ │ ├── Aload_2.java │ │ │ │ ├── Aload_3.java │ │ │ │ ├── Aload_0.java │ │ │ │ ├── Fload.java │ │ │ │ └── Iload.java │ │ │ └── store │ │ │ │ ├── Bastore.java │ │ │ │ ├── Castore.java │ │ │ │ ├── Sastore.java │ │ │ │ ├── Dstore_0.java │ │ │ │ ├── Dstore_1.java │ │ │ │ ├── Dstore_2.java │ │ │ │ ├── Dstore_3.java │ │ │ │ ├── Fstore_0.java │ │ │ │ ├── Fstore_1.java │ │ │ │ ├── Fstore_2.java │ │ │ │ ├── Fstore_3.java │ │ │ │ ├── Istore_0.java │ │ │ │ ├── Istore_1.java │ │ │ │ ├── Istore_2.java │ │ │ │ ├── Istore_3.java │ │ │ │ ├── Astore_0.java │ │ │ │ ├── Astore_1.java │ │ │ │ ├── Astore_2.java │ │ │ │ ├── Astore_3.java │ │ │ │ ├── Lstore_0.java │ │ │ │ ├── Lstore_1.java │ │ │ │ ├── Lstore_2.java │ │ │ │ ├── Lstore_3.java │ │ │ │ ├── Fstore.java │ │ │ │ ├── Lstore.java │ │ │ │ ├── Astore.java │ │ │ │ ├── Dstore.java │ │ │ │ └── Istore.java │ │ ├── methodinvocation │ │ │ ├── InvokeDynamic.java │ │ │ └── InvokeInterface.java │ │ ├── exception │ │ │ └── Athrow.java │ │ ├── typeconversion │ │ │ ├── D2f.java │ │ │ ├── D2i.java │ │ │ ├── D2l.java │ │ │ ├── F2d.java │ │ │ ├── F2i.java │ │ │ ├── F2l.java │ │ │ ├── I2b.java │ │ │ ├── I2c.java │ │ │ ├── I2f.java │ │ │ ├── I2l.java │ │ │ ├── I2s.java │ │ │ ├── L2d.java │ │ │ ├── L2f.java │ │ │ ├── L2i.java │ │ │ └── I2d.java │ │ ├── synchronization │ │ │ ├── MonitorExit.java │ │ │ └── MonitorEnter.java │ │ └── objectcreatemanipulate │ │ │ ├── Instanceof_.java │ │ │ ├── MultiANewArray.java │ │ │ └── CheckCast.java │ │ ├── draft │ │ ├── String.md │ │ ├── MainTest.java │ │ └── ReferenceTest.java │ │ ├── ZVM.java │ │ └── JavaMain.java └── test │ └── java │ └── Main.java └── javaclass ├── ch07 ├── Vector.java ├── InvokeInterfaceTest.java ├── Vector3D.java ├── InvokeSpecialTest.java ├── Vector2D.java └── InvokeVirtualTest.java ├── Simple1.java ├── Simple0.java ├── TestInterface.java ├── reflect └── T0Reflect0.java ├── ch08 ├── MultianewarrayDemo.java ├── Array1D.java ├── DoubleArray1D.java ├── StringTest.java ├── Array3D.java └── ArrayDemo.java ├── ch09 ├── StringBuilderTest.java └── ArrayDemo.java ├── GaussTest.java ├── jvmgo └── book │ ├── ch08 │ ├── Array1D.java │ └── DoubleArray1D.java │ └── ch09 │ └── ArrayDemo.java ├── FibonacciTest.java ├── RuntimeAnnotationTest.java ├── classlink ├── T0ClassLink.java └── T1ClassLink.java ├── stdlib └── basic │ └── thread │ └── T0ThreadTest.java ├── CreateAsyncThreadsTest.java └── gc └── GCTest0.java /draft/howtorun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/draft/howtorun.png -------------------------------------------------------------------------------- /bytecode/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/Person.class -------------------------------------------------------------------------------- /bytecode/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/Test.class -------------------------------------------------------------------------------- /bytecode/BaseTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/BaseTest.class -------------------------------------------------------------------------------- /bytecode/Simple0.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/Simple0.class -------------------------------------------------------------------------------- /bytecode/Simple1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/Simple1.class -------------------------------------------------------------------------------- /draft/howtorun_cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/draft/howtorun_cmd.png -------------------------------------------------------------------------------- /bytecode/GaussTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/GaussTest.class -------------------------------------------------------------------------------- /bytecode/ch07/Vector.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/Vector.class -------------------------------------------------------------------------------- /bytecode/gc/GCTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/gc/GCTest.class -------------------------------------------------------------------------------- /bytecode/gc/GCTest0.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/gc/GCTest0.class -------------------------------------------------------------------------------- /bytecode/gc/GCTest1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/gc/GCTest1.class -------------------------------------------------------------------------------- /bytecode/gc/GCTest2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/gc/GCTest2.class -------------------------------------------------------------------------------- /bytecode/FibonacciTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/FibonacciTest.class -------------------------------------------------------------------------------- /bytecode/MyAnnotation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/MyAnnotation.class -------------------------------------------------------------------------------- /bytecode/TestInterface.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/TestInterface.class -------------------------------------------------------------------------------- /bytecode/ch07/Vector2D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/Vector2D.class -------------------------------------------------------------------------------- /bytecode/ch07/Vector3D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/Vector3D.class -------------------------------------------------------------------------------- /bytecode/ch08/Array1D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/Array1D.class -------------------------------------------------------------------------------- /bytecode/ch08/Array3D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/Array3D.class -------------------------------------------------------------------------------- /bytecode/AnnotationTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/AnnotationTest.class -------------------------------------------------------------------------------- /bytecode/ch07/InvokeDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/InvokeDemo.class -------------------------------------------------------------------------------- /bytecode/ch08/ArrayDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/ArrayDemo.class -------------------------------------------------------------------------------- /bytecode/ch08/StringTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/StringTest.class -------------------------------------------------------------------------------- /bytecode/ch09/ArrayDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch09/ArrayDemo.class -------------------------------------------------------------------------------- /bytecode/java/lang/Class.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Class.class -------------------------------------------------------------------------------- /bytecode/java/lang/Math.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Math.class -------------------------------------------------------------------------------- /bytecode/java/lang/Number.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Number.class -------------------------------------------------------------------------------- /bytecode/java/lang/Object.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Object.class -------------------------------------------------------------------------------- /bytecode/java/lang/String.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/String.class -------------------------------------------------------------------------------- /bytecode/java/lang/System.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/System.class -------------------------------------------------------------------------------- /bytecode/java/lang/Thread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Thread.class -------------------------------------------------------------------------------- /bytecode/java/util/Arrays.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/util/Arrays.class -------------------------------------------------------------------------------- /bytecode/ch08/DoubleArray1D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/DoubleArray1D.class -------------------------------------------------------------------------------- /bytecode/java/lang/Integer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Integer.class -------------------------------------------------------------------------------- /bytecode/java/lang/String$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/String$1.class -------------------------------------------------------------------------------- /bytecode/java/lang/System$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/System$1.class -------------------------------------------------------------------------------- /bytecode/java/lang/System$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/System$2.class -------------------------------------------------------------------------------- /bytecode/java/lang/Thread$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Thread$1.class -------------------------------------------------------------------------------- /bytecode/RuntimeAnnotationTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/RuntimeAnnotationTest.class -------------------------------------------------------------------------------- /bytecode/ch08/BubbleSortTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/BubbleSortTest.class -------------------------------------------------------------------------------- /bytecode/classlink/T0ClassLink.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/classlink/T0ClassLink.class -------------------------------------------------------------------------------- /bytecode/classlink/T1ClassLink.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/classlink/T1ClassLink.class -------------------------------------------------------------------------------- /bytecode/java/io/OutputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/io/OutputStream.class -------------------------------------------------------------------------------- /bytecode/java/io/PrintStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/io/PrintStream.class -------------------------------------------------------------------------------- /bytecode/ch07/InvokeSpecialTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/InvokeSpecialTest.class -------------------------------------------------------------------------------- /bytecode/ch07/InvokeVirtualTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/InvokeVirtualTest.class -------------------------------------------------------------------------------- /bytecode/ch08/MultianewarrayDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/MultianewarrayDemo.class -------------------------------------------------------------------------------- /bytecode/ch09/StringBuilderTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch09/StringBuilderTest.class -------------------------------------------------------------------------------- /bytecode/java/lang/StringBuilder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/StringBuilder.class -------------------------------------------------------------------------------- /bytecode/java/lang/Thread$Caches.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Thread$Caches.class -------------------------------------------------------------------------------- /bytecode/java/lang/Thread$State.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Thread$State.class -------------------------------------------------------------------------------- /bytecode/jvmgo/book/ch08/Array1D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/jvmgo/book/ch08/Array1D.class -------------------------------------------------------------------------------- /bytecode/ch07/InvokeInterfaceTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch07/InvokeInterfaceTest.class -------------------------------------------------------------------------------- /bytecode/ch08/DoubleBubbleSortTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/ch08/DoubleBubbleSortTest.class -------------------------------------------------------------------------------- /bytecode/java/io/FilterOutputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/io/FilterOutputStream.class -------------------------------------------------------------------------------- /bytecode/java/io/ObjectStreamField.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/io/ObjectStreamField.class -------------------------------------------------------------------------------- /bytecode/java/util/Arrays$ArrayList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/util/Arrays$ArrayList.class -------------------------------------------------------------------------------- /bytecode/nestedclass/AnonymousClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/nestedclass/AnonymousClass.class -------------------------------------------------------------------------------- /bytecode/nestedclass/T0NestedClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/nestedclass/T0NestedClass.class -------------------------------------------------------------------------------- /src/main/java/com/zvm/basestruct/U1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.basestruct; 2 | 3 | public class U1 { 4 | public byte[] u1 ; 5 | } -------------------------------------------------------------------------------- /src/main/java/com/zvm/basestruct/U2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.basestruct; 2 | 3 | public class U2 { 4 | public byte[] u2 ; 5 | } -------------------------------------------------------------------------------- /bytecode/nestedclass/T0NestedClass$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/nestedclass/T0NestedClass$1.class -------------------------------------------------------------------------------- /src/main/java/com/zvm/basestruct/U4.java: -------------------------------------------------------------------------------- 1 | package com.zvm.basestruct; 2 | 3 | public class U4 { 4 | public byte[] u4 ; 5 | } 6 | -------------------------------------------------------------------------------- /bytecode/com/zvm/javaclass/integer/Son.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/com/zvm/javaclass/integer/Son.class -------------------------------------------------------------------------------- /bytecode/com/zvm/javaclass/integer/Table.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/com/zvm/javaclass/integer/Table.class -------------------------------------------------------------------------------- /bytecode/java/lang/AbstractStringBuilder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/AbstractStringBuilder.class -------------------------------------------------------------------------------- /bytecode/java/lang/Integer$IntegerCache.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Integer$IntegerCache.class -------------------------------------------------------------------------------- /bytecode/java/lang/Thread$WeakClassKey.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Thread$WeakClassKey.class -------------------------------------------------------------------------------- /bytecode/java/util/Arrays$NaturalOrder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/util/Arrays$NaturalOrder.class -------------------------------------------------------------------------------- /javaclass/ch07/Vector.java: -------------------------------------------------------------------------------- 1 | package ch07; 2 | 3 | public interface Vector { 4 | 5 | public void multiply(double s); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /bytecode/com/zvm/javaclass/integer/Table1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/com/zvm/javaclass/integer/Table1.class -------------------------------------------------------------------------------- /bytecode/java/util/Arrays$LegacyMergeSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/util/Arrays$LegacyMergeSort.class -------------------------------------------------------------------------------- /bytecode/com/zvm/javaclass/integer/Table1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/com/zvm/javaclass/integer/Table1$1.class -------------------------------------------------------------------------------- /bytecode/nestedclass/T0NestedClass$1LocalClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/nestedclass/T0NestedClass$1LocalClass.class -------------------------------------------------------------------------------- /bytecode/nestedclass/T0NestedClass$GenaralClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/nestedclass/T0NestedClass$GenaralClass.class -------------------------------------------------------------------------------- /bytecode/nestedclass/T0NestedClass$StaticClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/nestedclass/T0NestedClass$StaticClass.class -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/AttributeBase.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | public class AttributeBase { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JType.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | /** 4 | * 1.作为类型base 5 | */ 6 | public class JType { 7 | 8 | } -------------------------------------------------------------------------------- /bytecode/java/lang/Thread$UncaughtExceptionHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Thread$UncaughtExceptionHandler.class -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantBase.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | public class ConstantBase { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /bytecode/java/lang/Math$RandomNumberGeneratorHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/Math$RandomNumberGeneratorHolder.class -------------------------------------------------------------------------------- /bytecode/java/lang/String$CaseInsensitiveComparator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tzh476/zvm/HEAD/bytecode/java/lang/String$CaseInsensitiveComparator.class -------------------------------------------------------------------------------- /javaclass/Simple1.java: -------------------------------------------------------------------------------- 1 | public class Simple1 { 2 | public static void main(String[] args){ 3 | System.out.println("hello zvm!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/StackMapFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | public class StackMapFrame { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/java/Main.java: -------------------------------------------------------------------------------- 1 | public class Main { 2 | public static void main(String[] args){ 3 | byte b = (byte) 0x8d; 4 | System.out.println(0xff & b); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /javaclass/Simple0.java: -------------------------------------------------------------------------------- 1 | public class Simple0 { 2 | public static void main(String[] args){ 3 | int a = 11; 4 | int b = 999; 5 | int c = a + b; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/ElementValue.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | public class ElementValue { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/CpInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile; 2 | 3 | import com.zvm.classfile.constantpool.ConstantBase; 4 | 5 | public class CpInfo { 6 | public ConstantBase[] cpInfo; 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeVisibleTypeAnnotations/TypeAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.RuntimeVisibleTypeAnnotations; 2 | 3 | public class TypeAnnotation { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/VerificationTypeInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | public class VerificationTypeInfo { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/interpreter/Descriptor.java: -------------------------------------------------------------------------------- 1 | package com.zvm.interpreter; 2 | 3 | import java.util.List; 4 | 5 | public class Descriptor { 6 | public List parameters; 7 | public Integer returnType; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JChar.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JChar extends JType { 4 | public char value; 5 | public JChar(char value) { 6 | this.value = value; 7 | } 8 | } -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JByte.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JByte extends JType{ 4 | public byte value; 5 | public JByte(byte value){ 6 | this.value = value; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /javaclass/TestInterface.java: -------------------------------------------------------------------------------- 1 | 2 | interface TestInterface { 3 | final static Integer A = 10; 4 | final Integer B = 10; 5 | final String C = "13241d"; 6 | String D = "hellolll"; 7 | 8 | public void interfaceMethod(); 9 | } -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/ZvmClassLoader.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile; 2 | 3 | public class ZvmClassLoader extends ClassLoader { 4 | String bootClasspath ; 5 | String extClasspath; 6 | String userClasspath; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /javaclass/reflect/T0Reflect0.java: -------------------------------------------------------------------------------- 1 | package reflect; 2 | 3 | public class T0Reflect0 { 4 | public static void main(String[] args) { 5 | System.out.println(T0Reflect0.class.getName()); // jvmgo.book.ch09.GetClassTest 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JInt.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JInt extends JType{ 4 | public int value; 5 | public JInt(int value){ 6 | this.value = value; 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JLong.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JLong extends JType{ 4 | public long value; 5 | public JLong(long value){ 6 | this.value = value; 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JFloat.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JFloat extends JType{ 4 | public float value; 5 | public JFloat(float value){ 6 | this.value = value; 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JShort.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JShort extends JType{ 4 | public short value; 5 | public JShort(short value){ 6 | this.value = value; 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/MethodParameters/Parameter.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.MethodParameters; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class Parameter { 6 | public U2 nameIndex; 7 | public U2 accessFlags; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/lineNumberTable/LineNumber.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.lineNumberTable; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class LineNumber { 6 | public U2 startPc; 7 | public U2 lineNumber; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JDouble.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | public class JDouble extends JType{ 4 | public double value; 5 | public JDouble(double value){ 6 | this.value = value; 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/code/ExceptionTable.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.code; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class ExceptionTable { 6 | public U2 startPc; 7 | public U2 endPc; 8 | public U2 handlerPc; 9 | public U2 catchType; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/SameFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class SameFrame extends StackMapFrame { 6 | public U1 same = new U1(); 7 | public U1 frameType = same;/* 0-63 */ 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantFloat.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class ConstantFloat extends ConstantBase { 7 | public U1 tag; 8 | public U4 bytes; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantClass.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantClass extends ConstantBase { 7 | public U1 tag; 8 | public U2 nameIndex; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantInteger.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class ConstantInteger extends ConstantBase { 7 | public U1 tag; 8 | public U4 bytes; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/BootstrapMethod.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class BootstrapMethod { 6 | public U2 bootstrapMethodRef; 7 | public U2 numBootstrapArguments; 8 | public U2[] bootstrapArguments; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/ElementValuePair.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class ElementValuePair { 6 | public U2 elementNameIndex; 7 | public ElementValue value; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantString.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantString extends ConstantBase { 7 | public U1 tag; 8 | public U2 stringIndex; 9 | } 10 | -------------------------------------------------------------------------------- /javaclass/ch08/MultianewarrayDemo.java: -------------------------------------------------------------------------------- 1 | package ch08; 2 | 3 | public class MultianewarrayDemo { 4 | 5 | public static void main(String[] args) { 6 | new MultianewarrayDemo().test(); 7 | } 8 | 9 | public void test() { 10 | int[][][] x = new int[3][4][5]; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/ValueAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class ValueAnnotation extends ElementValue { 6 | public U1 tag; 7 | public Annotation annotationValue; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantMethodtype.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantMethodtype extends ConstantBase { 7 | public U1 tag; 8 | public U2 descriptorIndex; 9 | } 10 | -------------------------------------------------------------------------------- /javaclass/ch09/StringBuilderTest.java: -------------------------------------------------------------------------------- 1 | package ch09; 2 | 3 | public class StringBuilderTest { 4 | public static void main(String[] args) { 5 | String hello = "hello,"; 6 | String world = "world!"; 7 | String str = hello + world; 8 | System.out.println(str); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/DeprecatedAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class DeprecatedAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/SyntheticAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class SyntheticAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantUtf8.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantUtf8 extends ConstantBase { 7 | public U1 tag; 8 | public U2 length; 9 | public U1[] bytes; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/interpreter/Ref.java: -------------------------------------------------------------------------------- 1 | package com.zvm.interpreter; 2 | 3 | /** 4 | * 表示Constant_methodRef/Constant_field解析后的className、descriptorName、methodName/fieldName 5 | */ 6 | public class Ref { 7 | public String className; 8 | public String descriptorName; 9 | public String refName; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JArray.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | /** 4 | * 暂未使用 5 | */ 6 | public class JArray extends JType { 7 | 8 | /** 9 | * 数组的长度*/ 10 | public int length = 0; 11 | 12 | /** 13 | * 数组在heap的偏移量 14 | */ 15 | public Integer offset; 16 | } 17 | -------------------------------------------------------------------------------- /javaclass/GaussTest.java: -------------------------------------------------------------------------------- 1 | 2 | public class GaussTest { 3 | public GaussTest() { 4 | } 5 | 6 | public static void main(String[] args) { 7 | int sum = 0; 8 | 9 | for(int i = 5; i <= 20; i += 10) { 10 | sum += i; 11 | } 12 | 13 | System.out.println(sum); 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantDouble.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class ConstantDouble extends ConstantBase { 7 | public U1 tag; 8 | public U4 highBytes; 9 | public U4 lowBytes; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantLong.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class ConstantLong extends ConstantBase { 7 | public U1 tag; 8 | public U4 highBytes; 9 | public U4 lowBytes; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/Slot.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | /** 4 | * 5 | */ 6 | public class Slot { 7 | /** 8 | * value用于填充基本数据类型,double、long需要两个slot填充,对应jType为空 9 | */ 10 | public int value; 11 | /** 12 | * jType用于表示对象 13 | */ 14 | public JType jType; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/innerClasses/Classes.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.innerClasses; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class Classes { 6 | public U2 innerClassInfoIndex; 7 | public U2 outerClassInfoIndex; 8 | public U2 innerNameIndex; 9 | public U2 innerClassAccessFlags; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantFieldref.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantFieldref extends ConstantBase { 7 | public U1 tag; 8 | public U2 classIndex; 9 | public U2 nameAndTypeIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantMethodref.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantMethodref extends ConstantBase { 7 | public U1 tag; 8 | public U2 classIndex; 9 | public U2 nameAndTypeIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/jnative/NativeMethod.java: -------------------------------------------------------------------------------- 1 | package com.zvm.jnative; 2 | 3 | import com.zvm.runtime.JavaFrame; 4 | import com.zvm.runtime.RunTimeEnv; 5 | 6 | public interface NativeMethod { 7 | /** 8 | * 调用本地方法 9 | * @param javaFrame 10 | */ 11 | void invoke(RunTimeEnv runTimeEnv, JavaFrame javaFrame); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/LocalVariableTable/LocalVariable.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.LocalVariableTable; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class LocalVariable { 6 | public U2 startPc; 7 | public U2 length; 8 | public U2 nameIndex; 9 | public U2 descriptorIndex; 10 | public U2 index; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/SignatureAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class SignatureAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | public U2 signatureIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantNameandtype.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantNameandtype extends ConstantBase { 7 | public U1 tag; 8 | public U2 nameIndex; 9 | public U2 descriptorIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/SourceFileAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class SourceFileAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | public U2 sourcefileIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/ClassInfoIndex.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ClassInfoIndex extends ElementValue { 7 | public U1 tag; 8 | public U2 classInfoIndex; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/ConstValueIndex.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstValueIndex extends ElementValue { 7 | public U1 tag; 8 | public U2 constValueIndex; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/TopVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class TopVariableInfo extends VerificationTypeInfo { 6 | public U1 itemTop = new U1(); 7 | public U1 tag = itemTop; /* 0 */ 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantMethodhandle.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantMethodhandle extends ConstantBase { 7 | public U1 tag; 8 | public U1 referenceKind; 9 | public U2 referenceIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/Annotation.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class Annotation { 6 | public U2 typeIndex; 7 | public U2 numElementValuePairs; 8 | public ElementValuePair[] elementValuePairs; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/NullVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class NullVariableInfo extends VerificationTypeInfo { 6 | public U1 itemNull = new U1(); 7 | public U1 tag = itemNull; /* 5 */ 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/LocalVariableTypeTable/LocalVariableType.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.LocalVariableTypeTable; 2 | 3 | import com.zvm.basestruct.U2; 4 | 5 | public class LocalVariableType { 6 | public U2 startPc; 7 | public U2 length; 8 | public U2 nameIndex; 9 | public U2 signatureIndex; 10 | public U2 index; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/LongVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class LongVariableInfo extends VerificationTypeInfo { 6 | public U1 itemLong = new U1(); 7 | public U1 tag = itemLong; /* 4 */ 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantInterfacemethodref.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantInterfacemethodref extends ConstantBase { 7 | public U1 tag; 8 | public U2 classIndex; 9 | public U2 nameAndTypeIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/constantpool/ConstantInvokedynamic.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.constantpool; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ConstantInvokedynamic extends ConstantBase { 7 | public U1 tag; 8 | public U2 bootstrapMethodAttrIndex; 9 | public U2 nameAndTypeIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/ConstantValueAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class ConstantValueAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | public U2 constantvalueIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/ArrayValue.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ArrayValue extends ElementValue { 7 | public U1 tag; 8 | public U2 numValues; 9 | public ElementValue[] values; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/ChopFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ChopFrame extends StackMapFrame { 7 | public U1 chop = new U1(); 8 | public U1 frameType = chop; /* 248-250 */ 9 | public U2 offsetDelta; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/struct/JObject.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime.struct; 2 | 3 | import com.zvm.runtime.JavaClass; 4 | 5 | /** 6 | * 实例对象 7 | */ 8 | public class JObject extends JType{ 9 | /** 10 | * 实例对象所属的类的引用 11 | */ 12 | public JavaClass javaClass; 13 | /** 14 | * 实例对象在heap的偏移量 15 | */ 16 | public Integer offset; 17 | } -------------------------------------------------------------------------------- /javaclass/ch08/Array1D.java: -------------------------------------------------------------------------------- 1 | package ch08; 2 | 3 | public class Array1D { 4 | public static void main(String[] args) { 5 | int[] oneD = new int[5]; 6 | for (int i = 0; i < 5; ++i) { 7 | oneD[i] = 100 + i; 8 | } 9 | for (int i = 0; i < 5; ++i) { 10 | System.out.println(oneD[i]); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/EnclosingMethodAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class EnclosingMethodAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | public U2 classIndex; 10 | public U2 methodIndex; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/runtimeVisibleAnnotations/EnumConstValue.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.runtimeVisibleAnnotations; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class EnumConstValue extends ElementValue { 7 | public U1 tag; 8 | public U2 typeNameIndex; 9 | public U2 constNameIndex; 10 | } 11 | -------------------------------------------------------------------------------- /javaclass/ch08/DoubleArray1D.java: -------------------------------------------------------------------------------- 1 | package ch08; 2 | 3 | public class DoubleArray1D { 4 | public static void main(String[] args) { 5 | double[] oneD = new double[5]; 6 | for (int i = 0; i < 5; ++i) { 7 | oneD[i] = 100.1 + i; 8 | } 9 | for (int i = 0; i < 5; ++i) { 10 | System.out.println(oneD[i]); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javaclass/jvmgo/book/ch08/Array1D.java: -------------------------------------------------------------------------------- 1 | package jvmgo.book.ch08; 2 | 3 | public class Array1D { 4 | public static void main(String[] args) { 5 | int[] oneD = new int[5]; 6 | for (int i = 0; i < 5; ++i) { 7 | oneD[i] = 100 + i; 8 | } 9 | for (int i = 0; i < 5; ++i) { 10 | System.out.println(oneD[i]); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/ExceptionsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class ExceptionsAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | public U2 numberOfExceptions; 10 | public U2[] exceptionIndexTable; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/FloatVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class FloatVariableInfo extends VerificationTypeInfo { 6 | public U1 itemFloat = new U1(); 7 | /** 8 | * 2 */ 9 | public U1 tag = itemFloat; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/DoubleVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class DoubleVariableInfo extends VerificationTypeInfo { 6 | public U1 itemDouble = new U1(); 7 | /** 8 | * 3 */ 9 | public U1 tag = itemDouble; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/StaticVars.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime; 2 | 3 | 4 | import com.zvm.runtime.struct.Slot; 5 | 6 | public class StaticVars extends Vars { 7 | public StaticVars(Integer staticSlotCount) { 8 | slots = new Slot[staticSlotCount]; 9 | for(Integer i = 0; i < staticSlotCount; i++){ 10 | slots[i] = new Slot(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/SameFrameExtended.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class SameFrameExtended extends StackMapFrame { 7 | public U1 sameFrameExtended = new U1(); 8 | public U1 frameType = sameFrameExtended; /* 251 */ 9 | public U2 offsetDelta; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/IntegerVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class IntegerVariableInfo extends VerificationTypeInfo { 6 | public U1 itemInteger = new U1(); 7 | /** 8 | * 1 */ 9 | public U1 tag = itemInteger; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/UninitializedThisVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | 5 | public class UninitializedThisVariableInfo extends VerificationTypeInfo { 6 | public U1 itemUninitializedthis = new U1(); 7 | public U1 tag = itemUninitializedthis; /* 6 */ 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/LocalVars.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime; 2 | 3 | import com.zvm.runtime.struct.Slot; 4 | 5 | /** 6 | * 局部变量表 7 | */ 8 | public class LocalVars extends Vars { 9 | public LocalVars(Integer maxLocals) { 10 | slots = new Slot[maxLocals]; 11 | for(Integer i = 0; i < maxLocals; i++){ 12 | slots[i] = new Slot(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /javaclass/FibonacciTest.java: -------------------------------------------------------------------------------- 1 | 2 | public class FibonacciTest { 3 | public static void main(String[] args) { 4 | long x = fibonacci(8); 5 | System.out.println(x); 6 | } 7 | private static long fibonacci(long n) { 8 | if (n <= 1) { 9 | return n; 10 | } else { 11 | return fibonacci(n - 1) + fibonacci(n - 2); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/SourceDebugExtensionAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.basestruct.U4; 6 | 7 | public class SourceDebugExtensionAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U1[] debugExtension; 11 | } 12 | -------------------------------------------------------------------------------- /javaclass/jvmgo/book/ch08/DoubleArray1D.java: -------------------------------------------------------------------------------- 1 | package jvmgo.book.ch08; 2 | 3 | public class DoubleArray1D { 4 | public static void main(String[] args) { 5 | double[] oneD = new double[5]; 6 | for (int i = 0; i < 5; ++i) { 7 | oneD[i] = 100.1 + i; 8 | } 9 | for (int i = 0; i < 5; ++i) { 10 | System.out.println(oneD[i]); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/BootstrapMethodsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | 6 | public class BootstrapMethodsAttribute extends AttributeBase { 7 | public U2 attributeNameIndex; 8 | public U4 attributeLength; 9 | public U2 numBootstrapMethods; 10 | public BootstrapMethod[] bootstrapMethods; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeVisibleParameterAnnotations/ParameterAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.RuntimeVisibleParameterAnnotations; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.classfile.attribute.runtimeVisibleAnnotations.Annotation; 5 | 6 | public class ParameterAnnotation { 7 | public U2 numAnnotations; 8 | public Annotation[] annotations; 9 | } 10 | -------------------------------------------------------------------------------- /javaclass/ch07/InvokeInterfaceTest.java: -------------------------------------------------------------------------------- 1 | package ch07; 2 | 3 | public class InvokeInterfaceTest { 4 | 5 | public static void main(String[] args) { 6 | Vector v = new Vector3D(3.1, 3.2, 3.3); 7 | v.multiply(3); 8 | 9 | Vector3D v3 = (Vector3D) v; 10 | System.out.println(v3.x); 11 | System.out.println(v3.y); 12 | System.out.println(v3.z); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/ObjectVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class ObjectVariableInfo extends VerificationTypeInfo { 7 | public U1 itemObject = new U1(); 8 | public U1 tag = itemObject; /* 7 */ 9 | public U2 cpoolIndex; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/InnerClassesAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.innerClasses.Classes; 6 | 7 | public class InnerClassesAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 numberOfClasses; 11 | public Classes[] classes; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/AnnotationDefaultAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.runtimeVisibleAnnotations.ElementValue; 6 | 7 | public class AnnotationDefaultAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public ElementValue defaultValue; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/verificationtypeinfo/UninitializedVariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | 6 | public class UninitializedVariableInfo extends VerificationTypeInfo { 7 | public U1 itemUninitialized = new U1(); 8 | public U1 tag = itemUninitialized; /* 8 */ 9 | public U2 offset; 10 | } 11 | -------------------------------------------------------------------------------- /javaclass/ch07/Vector3D.java: -------------------------------------------------------------------------------- 1 | package ch07; 2 | 3 | public class Vector3D extends Vector2D { 4 | 5 | protected double z; 6 | 7 | public Vector3D() { 8 | this(1, 1, 1); 9 | } 10 | 11 | public Vector3D(double x, double y, double z) { 12 | super(x, y); 13 | this.z = z; 14 | } 15 | 16 | @Override 17 | public void multiply(double s) { 18 | super.multiply(s); 19 | this.z *= s; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/LineNumberTableAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.lineNumberTable.LineNumber; 6 | 7 | public class LineNumberTableAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 lineNumberTableLength; 11 | public LineNumber[] lineNumbers; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/StackMapTableAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.stackmaptable.StackMapFrame; 6 | 7 | public class StackMapTableAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 numberOfEntries; 11 | public StackMapFrame[] entries; 12 | } 13 | -------------------------------------------------------------------------------- /javaclass/ch07/InvokeSpecialTest.java: -------------------------------------------------------------------------------- 1 | package ch07; 2 | 3 | public class InvokeSpecialTest { 4 | 5 | public static void main(String[] args) { 6 | Vector2D v2 = new Vector2D(2.1, 2.2); 7 | System.out.println(v2.x); 8 | System.out.println(v2.y); 9 | 10 | Vector3D v3 = new Vector3D(3.1, 3.2, 3.3); 11 | System.out.println(v3.x); 12 | System.out.println(v3.y); 13 | System.out.println(v3.z); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /javaclass/ch07/Vector2D.java: -------------------------------------------------------------------------------- 1 | package ch07; 2 | 3 | public class Vector2D implements Vector { 4 | 5 | protected double x; 6 | protected double y; 7 | 8 | public Vector2D() { 9 | this(1, 1); 10 | } 11 | 12 | public Vector2D(double x, double y) { 13 | this.x = x; 14 | this.y = y; 15 | } 16 | 17 | @Override 18 | public void multiply(double s) { 19 | this.x *= s; 20 | this.y *= s; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/jnative/NativeConstant.java: -------------------------------------------------------------------------------- 1 | package com.zvm.jnative; 2 | 3 | public class NativeConstant { 4 | /** 5 | * registerNative("", "(Ljava/lang/Object;ILjava/lang/Object;II)V", "arraycopy"); 6 | */ 7 | public static String ARRAYCOPY_CLASSNAME = "java/lang/System"; 8 | public static String ARRAYCOPY_DESCRIPTOR = "(Ljava/lang/Object;ILjava/lang/Object;II)V"; 9 | public static String ARRAYCOPY_METHODNAME = "arraycopy"; 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/LocalVariableTableAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.LocalVariableTable.LocalVariable; 6 | 7 | public class LocalVariableTableAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 localVariableTableLength; 11 | public LocalVariable[] localVariables; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/MethodParametersAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.basestruct.U4; 6 | import com.zvm.classfile.attribute.MethodParameters.Parameter; 7 | 8 | public class MethodParametersAttribute extends AttributeBase { 9 | public U2 attributeNameIndex; 10 | public U4 attributeLength; 11 | public U1 parametersCount; 12 | Parameter[] parameters; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeVisibleAnnotationsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.runtimeVisibleAnnotations.Annotation; 6 | 7 | public class RuntimeVisibleAnnotationsAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 numAnnotations; 11 | public Annotation[] annotations; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeInvisibleAnnotationsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.runtimeVisibleAnnotations.Annotation; 6 | 7 | public class RuntimeInvisibleAnnotationsAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 numAnnotations; 11 | public Annotation[] annotations; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/MethodInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.runtime.JavaClass; 5 | import com.zvm.classfile.attribute.AttributeBase; 6 | 7 | public class MethodInfo { 8 | public U2 accessFlags; 9 | public U2 nameIndex; 10 | public U2 descriptorIndex; 11 | public U2 attributeCount; 12 | public AttributeBase[] attributes; 13 | 14 | public int argSlotCount = -1; 15 | public JavaClass javaClass; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/SameLocals1StackItemFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo.VerificationTypeInfo; 5 | 6 | public class SameLocals1StackItemFrame extends StackMapFrame { 7 | public U1 sameLocals1StackItem = new U1(); 8 | public U1 frameType = sameLocals1StackItem;/* 64-127 */ 9 | public VerificationTypeInfo[] stack; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/LocalVariableTypeTableAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.LocalVariableTypeTable.LocalVariableType; 6 | 7 | public class LocalVariableTypeTableAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 localVariableTypeTableLength; 11 | public LocalVariableType[] localVariableTypes; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeInvisibleTypeAnnotationsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.RuntimeVisibleTypeAnnotations.TypeAnnotation; 6 | 7 | public class RuntimeInvisibleTypeAnnotationsAttribute extends AttributeBase { 8 | public U2 attributeNameIndex; 9 | public U4 attributeLength; 10 | public U2 numAnnotations; 11 | TypeAnnotation[] annotations; 12 | } 13 | -------------------------------------------------------------------------------- /javaclass/ch07/InvokeVirtualTest.java: -------------------------------------------------------------------------------- 1 | package ch07; 2 | 3 | public class InvokeVirtualTest { 4 | 5 | public static void main(String[] args) { 6 | Vector2D v2 = new Vector2D(2.1, 2.2); 7 | Vector2D v3 = new Vector3D(3.1, 3.2, 3.3); 8 | v2.multiply(2); 9 | v3.multiply(3); 10 | System.out.println(v2.x); 11 | System.out.println(v2.y); 12 | System.out.println(v3.x); 13 | System.out.println(v3.y); 14 | System.out.println(((Vector3D)v3).z); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/FieldInfo.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.classfile.attribute.AttributeBase; 5 | import com.zvm.runtime.JavaClass; 6 | 7 | public class FieldInfo { 8 | public U2 accessFlags; 9 | public U2 nameIndex; 10 | public U2 descriptorIndex; 11 | public U2 attributeCount; 12 | public AttributeBase[] attributes; 13 | 14 | public int slotId; 15 | public int constValueIndex; 16 | 17 | public JavaClass javaClass; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeVisibleTypeAnnotationsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U2; 4 | import com.zvm.basestruct.U4; 5 | import com.zvm.classfile.attribute.RuntimeVisibleTypeAnnotations.TypeAnnotation; 6 | 7 | /** 8 | * java8增加 9 | */ 10 | public class RuntimeVisibleTypeAnnotationsAttribute extends AttributeBase { 11 | public U2 attributeNameIndex; 12 | public U4 attributeLength; 13 | public U2 numAnnotations; 14 | TypeAnnotation[] annotations; 15 | } 16 | -------------------------------------------------------------------------------- /javaclass/RuntimeAnnotationTest.java: -------------------------------------------------------------------------------- 1 | import java.lang.annotation.ElementType; 2 | import java.lang.annotation.Retention; 3 | import java.lang.annotation.RetentionPolicy; 4 | import java.lang.annotation.Target; 5 | 6 | /*https://blog.csdn.net/zhaominpro/article/details/82558600*/ 7 | @Target(ElementType.FIELD) 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @interface MyAnnotation1 { 10 | String color() default "red"; 11 | } 12 | 13 | 14 | public class RuntimeAnnotationTest { 15 | 16 | @MyAnnotation1(color = "blue") 17 | private String text; 18 | } -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/AppendFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo.VerificationTypeInfo; 6 | 7 | public class AppendFrame extends StackMapFrame { 8 | public U1 append = new U1(); 9 | /** 10 | * 252-254 11 | */ 12 | public U1 frameType = append; 13 | public U2 offsetDelta; 14 | public VerificationTypeInfo[] locals ; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/Ifnull.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Ifnull implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeVisibleParameterAnnotationsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.basestruct.U4; 6 | import com.zvm.classfile.attribute.RuntimeVisibleParameterAnnotations.ParameterAnnotation; 7 | 8 | public class RuntimeVisibleParameterAnnotationsAttribute extends AttributeBase { 9 | public U2 attributeNameIndex; 10 | public U4 attributeLength; 11 | public U1 numParameters; 12 | public ParameterAnnotation[] parameterAnnotations; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/RuntimeInvisibleParameterAnnotationsAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.basestruct.U4; 6 | import com.zvm.classfile.attribute.RuntimeVisibleParameterAnnotations.ParameterAnnotation; 7 | 8 | public class RuntimeInvisibleParameterAnnotationsAttribute extends AttributeBase { 9 | public U2 attributeNameIndex; 10 | public U4 attributeLength; 11 | public U1 numParameters; 12 | public ParameterAnnotation[] parameterAnnotations; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/draft/String.md: -------------------------------------------------------------------------------- 1 | StringBuilderTest.class中 String var1 = "hello,"; 调用链 2 | ``` 3 | ()V StringBuilder.() 4 | (I)V AbstractStringBuilder.() 5 | (Ljava/lang/String;)Ljava/lang/StringBuilder; StringBuilder.append() 6 | (Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; AbstractStringBuilder.append() 7 | (I)V AbstractStringBuilder.ensureCapacityInternal() 8 | (II[CI)V Stirng.getChars() 9 | (Ljava/lang/Object;ILjava/lang/Object;II)V System.arraycopy() --native方法 10 | ``` 11 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/SameLocals1StackItemFrameExtended.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo.VerificationTypeInfo; 6 | 7 | public class SameLocals1StackItemFrameExtended extends StackMapFrame { 8 | public U1 sameLocals1StackItemExtended = new U1(); 9 | public U1 frameType = sameLocals1StackItemExtended;/* 247 */ 10 | public U2 offsetDelta; 11 | public VerificationTypeInfo[] stack; 12 | } 13 | -------------------------------------------------------------------------------- /javaclass/ch08/StringTest.java: -------------------------------------------------------------------------------- 1 | package ch08; 2 | 3 | public class StringTest { 4 | 5 | public static final String STR = "abc"; 6 | 7 | public static void main(String[] args) { 8 | String s1 = "xyz"; // ldc 9 | 10 | System.out.println(STR); 11 | System.out.println(s1); 12 | //String s2 = "abc1"; 13 | //assertSame(s1, s2); 14 | 15 | //int x = 1; 16 | //String s3 = "abc" + x; 17 | //assertNotSame(s1, s3); 18 | 19 | //s3 = s3.intern(); 20 | //assertSame(s1, s3); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/Instruction.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction; 2 | 3 | import com.zvm.interpreter.CallSite; 4 | import com.zvm.interpreter.CodeUtils; 5 | import com.zvm.interpreter.Interpreter; 6 | import com.zvm.runtime.JThread; 7 | import com.zvm.runtime.JavaClass; 8 | import com.zvm.runtime.RunTimeEnv; 9 | 10 | /** 11 | * @author Rail 12 | */ 13 | public interface Instruction { 14 | /** 15 | * 执行指令 16 | */ 17 | void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Pop.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Pop implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | // System.out.println("未实现 " + this.getClass().getName()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Swap.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Swap implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | System.out.println("未实现 " + this.getClass().getName()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/stackmaptable/FullFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute.stackmaptable; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.classfile.attribute.stackmaptable.verificationtypeinfo.VerificationTypeInfo; 6 | 7 | public class FullFrame extends StackMapFrame { 8 | public U1 fullFrame = new U1(); 9 | public U1 frameType = fullFrame; /* 255 */ 10 | public U2 offsetDelta; 11 | public U2 numberOfLocals; 12 | public VerificationTypeInfo[] locals ; 13 | public U2 numberOfStackItems; 14 | public VerificationTypeInfo[] stack; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Irem.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Irem implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | System.out.println("未实现 " + this.getClass().getName()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Lmul.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lmul implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | System.out.println("未实现 " + this.getClass().getName()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/If_Acmpeq.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class If_Acmpeq implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | System.out.println("未实现 " + this.getClass().getName()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/Jsr.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Jsr implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/Jsr_W.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Jsr_W implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/Ret.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ret implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/Goto_W.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Goto_W implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Nop.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Nop implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/LookupSwitch.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class LookupSwitch implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/TableSwitch.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class TableSwitch implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/methodinvocation/InvokeDynamic.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.methodinvocation; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class InvokeDynamic implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/methodinvocation/InvokeInterface.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.methodinvocation; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class InvokeInterface implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /javaclass/classlink/T0ClassLink.java: -------------------------------------------------------------------------------- 1 | package classlink; 2 | 3 | /** 4 | * 类的生命周期 5 | * - 加载 6 | * - 链接 7 | * - 验证 8 | * - 准备 9 | * - 解析 10 | * - 初始化 11 | * - 使用 12 | * - 卸载 13 | */ 14 | public class T0ClassLink { 15 | public static int value1 = 132; 16 | public final static int FINAL_VALUE = 168; 17 | public static int[] arr = {1,3,5}; 18 | public final static int[] FINAL_ARR = {1,6,8}; 19 | 20 | public static void main(String[] args){ 21 | System.out.println(value1); 22 | System.out.println(FINAL_VALUE); 23 | System.out.println(arr[0]); 24 | System.out.println(FINAL_ARR[0]); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /javaclass/stdlib/basic/thread/T0ThreadTest.java: -------------------------------------------------------------------------------- 1 | package stdlib.basic.thread; 2 | 3 | public class T0ThreadTest { 4 | public static void main(String[] args) { 5 | Thread t = new Thread(new Runnable() { 6 | @Override 7 | public void run() { 8 | for (int i = 0; i < 1; i++) { 9 | System.out.println("run:"); 10 | System.out.println(i); 11 | } 12 | } 13 | }); 14 | t.start(); 15 | 16 | for (int i = 0; i < 1; i++) { 17 | System.out.println("main"); 18 | System.out.println(i); 19 | } 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/basestruct/TypeCode.java: -------------------------------------------------------------------------------- 1 | package com.zvm.basestruct; 2 | 3 | public class TypeCode { 4 | public final static Integer T_BOOLEAN = 4; 5 | public final static Integer T_CHAR = 5; 6 | public final static Integer T_FLOAT = 6; 7 | public final static Integer T_DOUBLE = 7; 8 | public final static Integer T_BYTE = 8; 9 | public final static Integer T_SHORT = 9; 10 | public final static Integer T_INT = 10; 11 | public final static Integer T_LONG = 11; 12 | 13 | public final static Integer T_EXTRA_VOID = 12; 14 | public final static Integer T_EXTRA_ARRAY = 13; 15 | public final static Integer T_EXTRA_OBJECT = 14; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/classfile/attribute/CodeAttribute.java: -------------------------------------------------------------------------------- 1 | package com.zvm.classfile.attribute; 2 | 3 | import com.zvm.basestruct.U1; 4 | import com.zvm.basestruct.U2; 5 | import com.zvm.basestruct.U4; 6 | import com.zvm.classfile.attribute.code.ExceptionTable; 7 | 8 | public class CodeAttribute extends AttributeBase { 9 | public U2 attributeNameIndex; 10 | public U4 attributeLength; 11 | public U2 maxStack; 12 | public U2 maxLocals; 13 | public U4 codeLength; 14 | public U1[] code; 15 | public U2 exceptionTableLength; 16 | public ExceptionTable[] exceptionTables; 17 | public U2 attributeCount; 18 | public AttributeBase[] attributes; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/exception/Athrow.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.exception; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Athrow implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/Wide.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Wide implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Dup2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Dup2 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Pop2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Pop2 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Dup2_X1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Dup2_X1 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Dup2_X2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Dup2_X2 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Dup_X1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Dup_X1 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Dup_X2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Dup_X2 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/D2f.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class D2f implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/D2i.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class D2i implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/D2l.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class D2l implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/F2d.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class F2d implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/F2i.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class F2i implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/F2l.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class F2l implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/I2b.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class I2b implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/I2c.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class I2c implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/I2f.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class I2f implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/I2l.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class I2l implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/I2s.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class I2s implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/L2d.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class L2d implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/L2f.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class L2f implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/L2i.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class L2i implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Ior.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ior implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Lor.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lor implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/logic/Iand.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.logic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Iand implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/logic/Land.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.logic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Land implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Dneg.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Dneg implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Fneg.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Fneg implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Ishl.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ishl implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Ishr.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ishr implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Iushr.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Iushr implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Ixor.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ixor implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Lneg.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lneg implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Lshl.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lshl implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Lshr.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lshr implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Lushr.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lushr implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Lxor.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lxor implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Baload.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.memory.ArrayFields; 8 | import com.zvm.runtime.*; 9 | import com.zvm.runtime.struct.JObject; 10 | 11 | public class Baload implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Caload.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Caload implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Saload.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Saload implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Ddiv.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ddiv implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Drem.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Drem implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Fdiv.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Fdiv implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Fmul.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Fmul implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Frem.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Frem implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Idiv.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Idiv implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Ldiv.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Ldiv implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Lrem.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Lrem implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/If_Acmpne.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class If_Acmpne implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Bastore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.memory.ArrayFields; 8 | import com.zvm.runtime.*; 9 | import com.zvm.runtime.struct.JObject; 10 | 11 | public class Bastore implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Castore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.memory.ArrayFields; 8 | import com.zvm.runtime.*; 9 | import com.zvm.runtime.struct.JObject; 10 | 11 | public class Castore implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Sastore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.memory.ArrayFields; 8 | import com.zvm.runtime.*; 9 | import com.zvm.runtime.struct.JObject; 10 | 11 | public class Sastore implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/synchronization/MonitorExit.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.synchronization; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class MonitorExit implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /javaclass/CreateAsyncThreadsTest.java: -------------------------------------------------------------------------------- 1 | import java.lang.Runnable; 2 | import java.lang.Thread; 3 | 4 | public class CreateAsyncThreadsTest { 5 | private static int cnt = 0; 6 | static class Task implements Runnable { 7 | @Override 8 | public void run() { 9 | System.out.print("This is "); 10 | for(int i=0;i<10;i++){ 11 | cnt++; 12 | } 13 | System.out.print(cnt); 14 | System.out.print( " times to say \"Hello World\"\n"); 15 | } 16 | } 17 | 18 | public static void main(String[] args){ 19 | for(int i=0;i<10;i++){ 20 | new Thread(new Task()).start(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /javaclass/ch08/Array3D.java: -------------------------------------------------------------------------------- 1 | package ch08; 2 | 3 | public class Array3D { 4 | 5 | public static void main(String[] args) { 6 | int[][][] threeD = new int[5][4][3]; 7 | 8 | for (int i = 0; i < 5; ++i) { 9 | for (int j = 0; j < 4; ++j) { 10 | for (int k = 0; k < 3; ++k) { 11 | threeD[i][j][k] = i + j + k; 12 | } 13 | } 14 | } 15 | 16 | for (int i = 0; i < 5; ++i) { 17 | for (int j = 0; j < 4; ++j) { 18 | for (int k = 0; k < 3; ++k) { 19 | System.out.println(threeD[i][j][k]); 20 | } 21 | } 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/synchronization/MonitorEnter.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.synchronization; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class MonitorEnter implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现 " + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/objectcreatemanipulate/Instanceof_.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.objectcreatemanipulate; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class Instanceof_ implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/ThreadStack.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime; 2 | 3 | /** 4 | * 运行时,表示整个线程的栈,可能存在一连串的方法帧 5 | */ 6 | public class ThreadStack { 7 | public Integer maxSize = 10; 8 | public Integer size; 9 | public JavaFrame topFrame; 10 | 11 | public ThreadStack(){ 12 | size = 0; 13 | } 14 | 15 | public void put(JavaFrame javaFrame){ 16 | javaFrame.lowerFrame = topFrame; 17 | topFrame = javaFrame; 18 | size ++; 19 | } 20 | 21 | public JavaFrame pop(){ 22 | JavaFrame popFrame = topFrame; 23 | topFrame = topFrame.lowerFrame; 24 | popFrame.lowerFrame = null; 25 | size --; 26 | return popFrame; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/objectcreatemanipulate/MultiANewArray.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.objectcreatemanipulate; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | public class MultiANewArray implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | System.out.println("未实现" + this.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/bitwise/Ineg.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.bitwise; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.JThread; 8 | import com.zvm.runtime.JavaClass; 9 | import com.zvm.runtime.RunTimeEnv; 10 | 11 | /** 12 | * 取反 13 | */ 14 | public class Ineg implements Instruction { 15 | @Override 16 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 17 | System.out.println("未实现 " + this.getClass().getName()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/ZVM.java: -------------------------------------------------------------------------------- 1 | package com.zvm; 2 | 3 | import com.zvm.interpreter.Interpreter; 4 | import com.zvm.runtime.JavaClass; 5 | import com.zvm.runtime.RunTimeEnv; 6 | 7 | public class ZVM { 8 | public static RunTimeEnv zvmEnv; 9 | public ZVM(RunTimeEnv zvmEnv){ 10 | ZVM.zvmEnv = zvmEnv; 11 | } 12 | 13 | public void callMain(String main, String descriptor, String classPath){ 14 | JavaClass javaClass = zvmEnv.methodArea.loadClass(classPath); 15 | Interpreter interpreter = new Interpreter(zvmEnv); 16 | interpreter.initInstructions(); 17 | zvmEnv.methodArea.linkClass(classPath); 18 | interpreter.invokeByName(javaClass, main, descriptor); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/JavaMain.java: -------------------------------------------------------------------------------- 1 | package com.zvm; 2 | 3 | import com.zvm.jnative.NativeUtils; 4 | import com.zvm.runtime.RunTimeEnv; 5 | 6 | public class JavaMain { 7 | public static void main(String[] args){ 8 | Cmd.processCmd(args); 9 | RunTimeEnv zvmEnv = new RunTimeEnv(); 10 | //String curClassNamePath = Cmd.curClassNamePath; 11 | String curClassName = Cmd.curClassName; 12 | System.out.println("file path : " + curClassName); 13 | 14 | ZVM zvm = new ZVM(zvmEnv); 15 | 16 | NativeUtils nativeUtils = new NativeUtils(); 17 | nativeUtils.registerNatives(); 18 | 19 | 20 | 21 | zvm.callMain("main", "([Ljava/lang/String;)V", curClassName); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/oprandstack/Dup.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.oprandstack; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dup implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putSlot(operandStack.getSlot()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/JavaFrame.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime; 2 | 3 | import com.zvm.utils.TypeUtils; 4 | import com.zvm.basestruct.U2; 5 | 6 | /** 7 | * 运行时,表示一个方法帧,lowerFrame指向调用者 8 | */ 9 | public class JavaFrame { 10 | /** 保留调用当前帧的帧*/ 11 | public JavaFrame lowerFrame; 12 | 13 | public Integer maxStack; 14 | public Integer maxLocals; 15 | 16 | public OperandStack operandStack; 17 | public LocalVars localVars; 18 | 19 | public JavaFrame(U2 maxStack, U2 maxLocals){ 20 | this.maxStack = TypeUtils.byteArr2Int(maxStack.u2); 21 | this.maxLocals = TypeUtils.byteArr2Int(maxLocals.u2); 22 | operandStack = new OperandStack(this.maxStack); 23 | localVars = new LocalVars(this.maxLocals); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(0); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(1); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_3 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(3); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_4.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_4 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(4); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_5.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_5 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(5); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/objectcreatemanipulate/CheckCast.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.objectcreatemanipulate; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class CheckCast implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | code.consumeU2(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/JThread.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime; 2 | 3 | 4 | import com.zvm.basestruct.U2; 5 | 6 | 7 | public class JThread { 8 | 9 | Integer pc; 10 | ThreadStack threadStack; 11 | 12 | 13 | public void pushFrame(U2 maxStack, U2 maxLocals){ 14 | if(threadStack == null){ 15 | threadStack = new ThreadStack(); 16 | } 17 | threadStack.put(new JavaFrame(maxStack, maxLocals)); 18 | } 19 | 20 | public JavaFrame popFrame(){ 21 | return threadStack.pop(); 22 | } 23 | 24 | public JavaFrame getTopFrame(){ 25 | JavaFrame topFrame = threadStack.topFrame; 26 | return topFrame; 27 | } 28 | 29 | public ThreadStack getStack(){ 30 | return threadStack; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Dconst_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dconst_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putDouble(0.0); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Dconst_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dconst_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putDouble(1.0); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Fconst_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fconst_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putFloat(0.0f); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Fconst_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fconst_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putFloat(1.0f); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Fconst_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fconst_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putFloat(2.0f); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Iconst_M1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iconst_M1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putInt(-1); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Lconst_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lconst_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putLong(0L); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Lconst_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lconst_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putLong(1L); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/runtime/RunTimeEnv.java: -------------------------------------------------------------------------------- 1 | package com.zvm.runtime; 2 | 3 | import com.zvm.gc.GC; 4 | import com.zvm.jnative.NativeMethod; 5 | import com.zvm.memory.JavaHeap; 6 | import com.zvm.memory.MethodArea; 7 | 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | /** 14 | * zvm运行环境 15 | */ 16 | public class RunTimeEnv { 17 | 18 | public JavaHeap javaHeap; 19 | public MethodArea methodArea; 20 | public static Map nativeMethodMap; 21 | 22 | public GC gc; 23 | 24 | public RunTimeEnv(){ 25 | methodArea = new MethodArea(); 26 | javaHeap = new JavaHeap(); 27 | nativeMethodMap = new HashMap<>(); 28 | gc = new GC(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Aconst_null.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Aconst_null implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | operandStack.putJObject(null); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /javaclass/ch08/ArrayDemo.java: -------------------------------------------------------------------------------- 1 | package ch08; 2 | 3 | public class ArrayDemo { 4 | 5 | public static void main(String[] args) { 6 | int[] a1 = new int[10]; // newarray 7 | String[] a2 = new String[10]; // anewarray 8 | //int[][] a3 = new int[10][10]; // multianewarray 9 | int x = a1.length; // arraylength 10 | a1[0] = 100; // iastore 11 | int y = a1[0]; // iaload 12 | a2[0] = "0abc"; // aastore 13 | String s = a2[0]; // aaload 14 | System.out.println( s); 15 | a2[1] = "1xxxxyyxyy"; 16 | a2[2] = "2xxxxyyxyy"; 17 | 18 | for(int i = 0; i < 3; i++){ 19 | System.out.println(a2[i]); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Dstore_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dstore_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putDouble(0, operandStack.popDouble()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Dstore_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dstore_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putDouble(1, operandStack.popDouble()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Dstore_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dstore_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putDouble(2, operandStack.popDouble()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Dstore_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dstore_3 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putDouble(3, operandStack.popDouble()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Fstore_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fstore_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putFloat(0, operandStack.popFloat()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Fstore_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fstore_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putFloat(1, operandStack.popFloat()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Fstore_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fstore_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putFloat(2, operandStack.popFloat()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Fstore_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fstore_3 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putFloat(3, operandStack.popFloat()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Istore_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Istore_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putIntByIndex(0, operandStack.popInt()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Istore_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Istore_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putIntByIndex(1, operandStack.popInt()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Istore_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Istore_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putIntByIndex(2, operandStack.popInt()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Istore_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Istore_3 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putIntByIndex(3, operandStack.popInt()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Iload_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iload_0 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | operandStack.putInt(localVars.getIntByIndex(0)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Iload_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iload_1 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | operandStack.putInt(localVars.getIntByIndex(1)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Iload_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iload_2 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | operandStack.putInt(localVars.getIntByIndex(2)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Iload_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iload_3 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | operandStack.putInt(localVars.getIntByIndex(3)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Astore_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Astore_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putJObject(0, operandStack.popJObject()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Astore_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Astore_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putJObject(1, operandStack.popJObject()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Astore_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Astore_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putJObject(2, operandStack.popJObject()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Astore_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Astore_3 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putJObject(3, operandStack.popJObject()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Lstore_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lstore_0 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putLong(0, operandStack.popLong()); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Lstore_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lstore_1 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putLong(1, operandStack.popLong()); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Lstore_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lstore_2 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putLong(2, operandStack.popLong()); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Lstore_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lstore_3 implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | localVars.putLong(3, operandStack.popLong()); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /javaclass/ch09/ArrayDemo.java: -------------------------------------------------------------------------------- 1 | package ch09; 2 | 3 | public class ArrayDemo { 4 | public static void main(String[] args) { 5 | int[] a1 = new int[10]; // newarray 6 | String[] a2 = new String[10]; // anewarray 7 | //int[][] a3 = new int[10][10]; // multianewarray 8 | int x = a1.length; // arraylength 9 | a1[0] = 100; // iastore 10 | int y = a1[0]; // iaload 11 | a2[0] = "0abc"; // aastore 12 | String s = a2[0]; // aaload 13 | System.out.println( s); 14 | a2[1] = "1xxxxyyxyy"; 15 | a2[2] = "2xxxxyyxyy"; 16 | 17 | for(int i = 0; i < 3; i++){ 18 | System.out.println(a2[i] + " stringbuilderTest"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/controltransfer/Goto_.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.controltransfer; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Goto_ implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | short offset = code.readU2(); 17 | code.pcAddBackOne(offset ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/draft/MainTest.java: -------------------------------------------------------------------------------- 1 | package com.zvm.draft; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.google.gson.Gson; 5 | import com.zvm.instruction.Opcode1; 6 | 7 | public class MainTest { 8 | public static void main(String[] args){ 9 | Gson gson = new Gson(); 10 | System.out.println(gson.toJson(new Opcode1())); 11 | } 12 | 13 | /** 14 | * fastjson转对象为json丢失所有属性 15 | */ 16 | public void fastJsonTest(){ 17 | Opcode2 opcode2 = new Opcode2(); 18 | System.out.println(opcode2.dup_x1); 19 | System.out.println(opcode2.toString()); 20 | System.out.println(JSON.toJSONString(opcode2)); 21 | Gson gson = new Gson(); 22 | System.out.println(gson.toJson(opcode2)); 23 | } 24 | } 25 | class Opcode2{ 26 | int dup_x1 =1110; 27 | } -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Bipush.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Bipush implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | byte byteConstant = code.consumeU1(); 17 | operandStack.putByte(byteConstant); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/constant/Sipush.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.constant; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Sipush implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | short shortConstant = code.consumeU2(); 17 | operandStack.putInt(shortConstant); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Fstore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fstore implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int index = code.consumeU1(); 17 | localVars.putFloat(index, operandStack.popFloat()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Lstore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lstore implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int index = code.consumeU1(); 17 | localVars.putLong(index, operandStack.popLong()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /javaclass/jvmgo/book/ch09/ArrayDemo.java: -------------------------------------------------------------------------------- 1 | package jvmgo.book.ch09; 2 | 3 | public class ArrayDemo { 4 | 5 | public static void main(String[] args) { 6 | int[] a1 = new int[10]; // newarray 7 | String[] a2 = new String[10]; // anewarray 8 | //int[][] a3 = new int[10][10]; // multianewarray 9 | int x = a1.length; // arraylength 10 | a1[0] = 100; // iastore 11 | int y = a1[0]; // iaload 12 | a2[0] = "0abc"; // aastore 13 | String s = a2[0]; // aaload 14 | System.out.println( s); 15 | a2[1] = "1xxxxyyxyy"; 16 | a2[2] = "2xxxxyyxyy"; 17 | 18 | for(int i = 0; i < 3; i++){ 19 | System.out.println(a2[i] + " stringbuilderTest"); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Fload_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fload_0 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | float loadValue = localVars.getFloat(0); 18 | operandStack.putFloat(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Fload_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fload_1 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | float loadValue = localVars.getFloat(1); 18 | operandStack.putFloat(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Fload_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fload_2 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | float loadValue = localVars.getFloat(2); 18 | operandStack.putFloat(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Fload_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fload_3 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | float loadValue = localVars.getFloat(3); 18 | operandStack.putFloat(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Astore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Astore implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int index = code.consumeU1(); 17 | localVars.putJObject(index, operandStack.popJObject()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Dstore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dstore implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int index = code.consumeU1(); 17 | localVars.putDouble(index, operandStack.popDouble()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Dload_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dload_0 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | double loadValue = localVars.getDouble(0); 18 | operandStack.putDouble(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Dload_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dload_1 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | double loadValue = localVars.getDouble(1); 18 | operandStack.putDouble(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Dload_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dload_2 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | double loadValue = localVars.getDouble(2); 18 | operandStack.putDouble(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Dload_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dload_3 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | double loadValue = localVars.getDouble(3); 18 | operandStack.putDouble(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Lload_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lload_0 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | long loadValue = localVars.getLongByIndex(0); 18 | operandStack.putLong(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Lload_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lload_1 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | long loadValue = localVars.getLongByIndex(1); 18 | operandStack.putLong(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Lload_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lload_2 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | long loadValue = localVars.getLongByIndex(2); 18 | operandStack.putLong(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Lload_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lload_3 implements Instruction { 10 | 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils codeUtils) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | long loadValue = localVars.getLongByIndex(3); 18 | operandStack.putLong(loadValue); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /javaclass/gc/GCTest0.java: -------------------------------------------------------------------------------- 1 | package gc; 2 | public class GCTest0 { 3 | 4 | 5 | public static void main(String[] args){ 6 | System.out.println("arr1 begin "); 7 | int[] arr1 = new int[5]; 8 | for (int i = 0; i < 5; ++i) { 9 | arr1[i] = 100 + i; 10 | } 11 | System.out.println("arr1 end "); 12 | 13 | System.out.println("arr2 begin "); 14 | int[] arr2 = new int[100]; 15 | for (int i = 0; i < 100; ++i) { 16 | arr2[i] = 100 + i; 17 | } 18 | System.out.println("arr2 end "); 19 | 20 | int[] arr3 = new int[200]; 21 | for (int i = 0; i < 200; ++i) { 22 | arr3[i] = 100 + i; 23 | } 24 | 25 | for (int i = 0; i < 5; ++i) { 26 | System.out.println(arr1[i]); 27 | } 28 | } 29 | 30 | 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/typeconversion/I2d.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.typeconversion; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class I2d implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int iValue = operandStack.popInt(); 17 | double dValue = iValue + 0.0; 18 | operandStack.putDouble(dValue); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /javaclass/classlink/T1ClassLink.java: -------------------------------------------------------------------------------- 1 | package classlink; 2 | 3 | /** 4 | * 类的生命周期 5 | * - 加载 6 | * - 链接 7 | * - 验证 8 | * - 准备 9 | * - 解析 10 | * - 初始化 11 | * - 使用 12 | * - 卸载 13 | */ 14 | public class T1ClassLink { 15 | public static String value1 = "abc"; 16 | public final static String FINAL_VALUE = "zvm"; 17 | public static String[] arr = {"arr0","arr1","dsafasfsdafd"}; 18 | public final static String[] FINAL_ARR = {"final-arr0","final-arr1","final-dsafasfsdafd"}; 19 | 20 | public String generalStr = "generalStr"; 21 | 22 | public static void main(String[] args){ 23 | System.out.println(value1); 24 | System.out.println(FINAL_VALUE); 25 | System.out.println(arr[0]); 26 | System.out.println(FINAL_ARR[0]); 27 | System.out.println(new T1ClassLink().generalStr); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Aload_1.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | import com.zvm.runtime.struct.JObject; 9 | 10 | public class Aload_1 implements Instruction { 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | JObject jObject = localVars.getJObject(1); 18 | operandStack.putJObject(jObject); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Aload_2.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | import com.zvm.runtime.struct.JObject; 9 | 10 | public class Aload_2 implements Instruction { 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | JObject jObject = localVars.getJObject(2); 18 | operandStack.putJObject(jObject); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Aload_3.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | import com.zvm.runtime.struct.JObject; 9 | 10 | public class Aload_3 implements Instruction { 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | JObject jObject = localVars.getJObject(3); 18 | operandStack.putJObject(jObject); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Iadd.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Iadd implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int var1 = operandStack.popInt(); 17 | int var0 = operandStack.popInt(); 18 | int sum = var0 + var1; 19 | operandStack.putInt(sum); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Imul.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Imul implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int var1 = operandStack.popInt(); 17 | int var0 = operandStack.popInt(); 18 | int sum = var0 * var1; 19 | operandStack.putInt(sum); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/draft/ReferenceTest.java: -------------------------------------------------------------------------------- 1 | package com.zvm.draft; 2 | 3 | /** 4 | * 对象引用测试 5 | */ 6 | public class ReferenceTest { 7 | public int value = 100; 8 | Student student = new Student(); 9 | public static void main(String[] args){ 10 | test1(); 11 | } 12 | 13 | /** 14 | * 正常打印 15 | */ 16 | static void test0(){ 17 | ReferenceTest r0 = new ReferenceTest(); 18 | ReferenceTest r1 = r0; 19 | r1 = null; 20 | System.out.println(r0.value); 21 | } 22 | 23 | /** 24 | * r0.next.value不正常打印 25 | */ 26 | static void test1(){ 27 | ReferenceTest r0 = new ReferenceTest(); 28 | ReferenceTest r1 = r0; 29 | r1.student = null; 30 | System.out.println(r0.value); 31 | System.out.println(r0.student.value); 32 | } 33 | } 34 | class Student{ 35 | public int value = 100; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Isub.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Isub implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | int var1 = operandStack.popInt(); 17 | int var0 = operandStack.popInt(); 18 | int subValue = var0 - var1; 19 | operandStack.putInt(subValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Ladd.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Ladd implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | long var1 = operandStack.popLong(); 17 | long var0 = operandStack.popLong(); 18 | long addValue = var0 + var1; 19 | operandStack.putLong(addValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Lsub.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Lsub implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | long var1 = operandStack.popLong(); 17 | long var0 = operandStack.popLong(); 18 | long subValue = var0 - var1; 19 | operandStack.putLong(subValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Aload_0.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | import com.zvm.runtime.struct.JObject; 9 | import com.zvm.utils.TypeUtils; 10 | 11 | public class Aload_0 implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | JavaFrame javaFrame = jThread.getTopFrame(); 15 | OperandStack operandStack = javaFrame.operandStack; 16 | LocalVars localVars = javaFrame.localVars; 17 | 18 | JObject jObject = localVars.getJObject(0); 19 | operandStack.putJObject(jObject); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Dmul.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dmul implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | double var1 = operandStack.popDouble(); 17 | double var0 = operandStack.popDouble(); 18 | double sum = var0 * var1; 19 | operandStack.putDouble(sum); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Fadd.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fadd implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | float var1 = operandStack.popFloat(); 17 | float var0 = operandStack.popFloat(); 18 | float addValue = var0 + var1; 19 | operandStack.putFloat(addValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Fsub.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Fsub implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | float var1 = operandStack.popFloat(); 17 | float var0 = operandStack.popFloat(); 18 | float subValue = var0 - var1; 19 | operandStack.putFloat(subValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Dsub.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dsub implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | double var1 = operandStack.popLong(); 17 | double var0 = operandStack.popLong(); 18 | double subValue = var0 - var1; 19 | operandStack.putDouble(subValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/store/Istore.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.store; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.memory.ArrayFields; 8 | import com.zvm.runtime.*; 9 | import com.zvm.runtime.struct.JObject; 10 | 11 | public class Istore implements Instruction { 12 | @Override 13 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 14 | JavaFrame javaFrame = jThread.getTopFrame(); 15 | OperandStack operandStack = javaFrame.operandStack; 16 | LocalVars localVars = javaFrame.localVars; 17 | 18 | int index = code.consumeU1(); 19 | localVars.putIntByIndex(index, operandStack.popInt()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/arithmetic/arithmetic/Dadd.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.arithmetic.arithmetic; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | 9 | public class Dadd implements Instruction { 10 | @Override 11 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 12 | JavaFrame javaFrame = jThread.getTopFrame(); 13 | OperandStack operandStack = javaFrame.operandStack; 14 | LocalVars localVars = javaFrame.localVars; 15 | 16 | double var1 = operandStack.popDouble(); 17 | double var0 = operandStack.popDouble(); 18 | double addValue = var0 + var1; 19 | operandStack.putDouble(addValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Fload.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | import com.zvm.utils.TypeUtils; 9 | 10 | public class Fload implements Instruction { 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | int index = TypeUtils.byte2Int(code.consumeU1()); 18 | float loadValue = localVars.getFloat(index); 19 | operandStack.putFloat(loadValue); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zvm/instruction/loadandstore/load/Iload.java: -------------------------------------------------------------------------------- 1 | package com.zvm.instruction.loadandstore.load; 2 | 3 | import com.zvm.instruction.Instruction; 4 | import com.zvm.interpreter.CallSite; 5 | import com.zvm.interpreter.CodeUtils; 6 | import com.zvm.interpreter.Interpreter; 7 | import com.zvm.runtime.*; 8 | import com.zvm.utils.TypeUtils; 9 | 10 | public class Iload implements Instruction { 11 | @Override 12 | public void execute(RunTimeEnv runTimeEnv, JThread jThread, JavaClass javaClass, CallSite callSite, Interpreter interpreter, CodeUtils code) { 13 | JavaFrame javaFrame = jThread.getTopFrame(); 14 | OperandStack operandStack = javaFrame.operandStack; 15 | LocalVars localVars = javaFrame.localVars; 16 | 17 | int index = TypeUtils.byte2Int(code.consumeU1()); 18 | int loadValue = localVars.getIntByIndex(index); 19 | operandStack.putInt(loadValue); 20 | } 21 | } 22 | --------------------------------------------------------------------------------