用Java实现JVM第八章《数组和字符串》

  • http://www.itstack.org

  • create by fuzhengwei on 2019/4/29

*/

public class NEW_ARRAY implements Instruction {

private byte atype;

@Override

public void fetchOperands(BytecodeReader reader) {

this.atype = reader.readByte();

}

@Override

public void execute(Frame frame) {

OperandStack stack = frame.operandStack();

int count = stack.popInt();

if (count < 0) {

throw new NegativeArraySizeException();

}

ClassLoader classLoader = frame.method().clazz().loader();

Class arrClass = getPrimitiveArrayClass(classLoader, this.atype);

Object arr = arrClass.newArray(count);

stack.pushRef(arr);

}

private Class getPrimitiveArrayClass(ClassLoader loader, byte atype){

switch (atype) {

case ArrayType.AT_BOOLEAN:

return loader.loadClass(“[Z”);

case ArrayType.AT_BYTE:

return loader.loadClass(“[B”);

case ArrayType.AT_CHAR:

return loader.loadClass(“[C”);

case ArrayType.AT_SHORT:

return loader.loadClass(“[S”);

case ArrayType.AT_INT:

return loader.loadClass(“[I”);

case ArrayType.AT_LONG:

return loader.loadClass(“[J”);

case ArrayType.AT_FLOAT:

return loader.loadClass(“[F”);

case ArrayType.AT_DOUBLE:

return loader.loadClass(“[D”);

default:

throw new RuntimeException(“Invalid atype!”);

}

}

static class ArrayType {

static final byte AT_BOOLEAN = 4;

static final byte AT_CHAR = 5;

static final byte AT_FLOAT = 6;

static final byte AT_DOUBLE = 7;

static final byte AT_BYTE = 8;

static final byte AT_SHORT = 9;

static final byte AT_INT = 10;

static final byte AT_LONG = 11;

}

}

IASTORE.java

package org.itstack.demo.jvm.instructions.stores.xastore;

import org.itstack.demo.jvm.instructions.base.InstructionNoOperands;

import org.itstack.demo.jvm.rtda.Frame;

import org.itstack.demo.jvm.rtda.OperandStack;

import org.itstack.demo.jvm.rtda.heap.methodarea.Object;

/**

  • http://www.itstack.org

  • create by fuzhengwei on 2019/4/29

*/

public class IASTORE extends InstructionNoOperands {

@Override

public void execute(Frame frame) {

OperandStack stack = frame.operandStack();

int val = stack.popInt();

int idx = stack.popInt();

Object arrRef = stack.popRef();

checkNotNull(arrRef);

int[] ints = arrRef.ints();

checkIndex(ints.length, idx);

ints[idx] = val;

}

}

StringPool.java

package org.itstack.demo.jvm.rtda.heap.methodarea;

import org.itstack.demo.jvm.rtda.heap.ClassLoader;

import java.util.HashMap;

import java.util.Map;

/**

  • http://www.itstack.org

  • create by fuzhengwei on 2019/4/29

*/

public class StringPool {

private static Map<String, Object> internedStrs = new HashMap<>();

public static Object jString(ClassLoader loader, String goStr) {

Object internedStr = internedStrs.get(goStr);

if (null != internedStr) return internedStr;

char[] chars = goStr.toCharArray();

Object jChars = new Object(loader.loadClass(“[C”), chars);

Object jStr = loader.loadClass(“java/lang/String”).newObject();

jStr.setRefVal(“value”, “[C”, jChars);

internedStrs.put(goStr, jStr);

return jStr;

}

public static String goString(Object jStr) {

Object charArr = jStr.getRefVar(“value”, “[C”);

return new String(charArr.chars());

}

}

Interpret.java

package org.itstack.demo.jvm;

import com.alibaba.fastjson.JSON;

import org.itstack.demo.jvm.instructions.Factory;

import org.itstack.demo.jvm.instructions.base.BytecodeReader;

import org.itstack.demo.jvm.instructions.base.Instruction;

import org.itstack.demo.jvm.rtda.Frame;

import org.itstack.demo.jvm.rtda.Thread;

import org.itstack.demo.jvm.rtda.heap.ClassLoader;

import org.itstack.demo.jvm.rtda.heap.methodarea.*;

import org.itstack.demo.jvm.rtda.heap.methodarea.Class;

import org.itstack.demo.jvm.rtda.heap.methodarea.Object;

//指令集解释器

class Interpret {

Interpret(Method method, boolean logInst, String args) {

Thread thread = new Thread();

Frame frame = thread.newFrame(method);

thread.pushFrame(frame);

if (null != args){

Object jArgs = createArgsArray(method.clazz().loader(), args.split(" "));

frame.localVars().setRef(0, jArgs);

}

loop(thread, logInst);

}

private Object createArgsArray(ClassLoader loader, String[] args) {

Class stringClass = loader.loadClass(“java/lang/String”);

Object argsArr = stringClass.arrayClass().newArray(args.length);

Object[] jArgs = argsArr.refs();

for (int i = 0; i < jArgs.length; i++) {

jArgs[i] = StringPool.jString(loader, args[i]);

}

return argsArr;

}

private void loop(Thread thread, boolean logInst) {

BytecodeReader reader = new BytecodeReader();

while (true) {

Frame frame = thread.currentFrame();

int pc = frame.nextPC();

thread.setPC(pc);

reader.reset(frame.method().code, pc);

byte opcode = reader.readByte();

Instruction inst = Factory.newInstruction(opcode);

if (null == inst) {

System.out.println("Unsupported opcode " + byteToHexString(new byte[]{opcode}));

break;

}

inst.fetchOperands(reader);

frame.setNextPC(reader.pc());

if (logInst) {

logInstruction(frame, inst, opcode);

}

//exec

inst.execute(frame);

if (thread.isStackEmpty()) {

break;

}

}

}

private static void logInstruction(Frame frame, Instruction inst, byte opcode) {

Method method = frame.method();

String className = method.clazz().name();

String methodName = method.name();

String outStr = (className + “.” + methodName + “() \t”) +

“寄存器(指令):” + byteToHexString(new byte[]{opcode}) + " -> " + inst.getClass().getSimpleName() + " => 局部变量表:" + JSON.toJSONString(frame.operandStack().getSlots()) + " 操作数栈:" + JSON.toJSONString(frame.operandStack().getSlots());

System.out.println(outStr);

}

private static String byteToHexString(byte[] codes) {

StringBuilder sb = new StringBuilder();

sb.append(“0x”);

for (byte b : codes) {

int value = b & 0xFF;

String strHex = Integer.toHexString(value);

if (strHex.length() < 2) {

strHex = “0” + strHex;

}

sb.append(strHex);

}

return sb.toString();

}

}

BubbleSortTest.java

package org.itstack.demo.test;

/**

  • -Xjre “C:\Program Files\Java\jdk1.8.0_161\jre” E:\itstack\git\istack-demo\itstack-demo-jvm\itstack-demo-jvm-08\target\test-classes\org\itstack\demo\test\BubbleSortTest -verbose true

*/

public class BubbleSortTest {

public static void main(String[] args) {

int[] arr = {

22, 84, 77, 11, 95, 9, 78, 56,

36, 97, 65, 36, 10, 24 ,92, 48

};

//printArray(arr);

bubbleSort(arr);

//System.out.println(123456789);

printArray(arr);

}

private static void bubbleSort(int[] arr) {

boolean swapped = true;

int j = 0;

int tmp;

while (swapped) {

swapped = false;

j++;

for (int i = 0; i < arr.length - j; i++) {

if (arr[i] > arr[i + 1]) {

tmp = arr[i];

arr[i] = arr[i + 1];

arr[i + 1] = tmp;

swapped = true;

}

}

}

}

private static void printArray(int[] arr) {

for (int i : arr) {

System.out.println(i);

}

}

}

HelloWorld.java

package org.itstack.demo.test;

/**

  • -Xjre “C:\Program Files\Java\jdk1.8.0_161\jre” E:\itstack\git\istack-demo\itstack-demo-jvm\itstack-demo-jvm-08\target\test-classes\org\itstack\demo\test\HelloWorld -verbose true -args 你好,java版虚拟机v1.0,欢迎你的到来。

*/

public class HelloWorld {

public static void main(String[] args) {

for (String str : args) {

System.out.println(str);

}

}

}

测试结果一;执行数组

-Xjre “C:\Program Files\Java\jdk1.8.0_161\jre” E:\itstack\git\istack-demo\itstack-demo-jvm\itstack-demo-jvm-08\target\test-classes\org\itstack\demo\test\BubbleSortTest -verbose true

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:0},{“num”:0},{“num”:0},{“num”:0}] 操作数栈:[{“num”:0},{“num”:0},{“num”:0},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0xbc -> NEW_ARRAY => 局部变量表:[{“num”:16},{“num”:0},{“num”:0},{“num”:0}] 操作数栈:[{“num”:16},{“num”:0},{“num”:0},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:0},{“num”:0},{“num”:0}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:0},{“num”:0},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x03 -> ICONST_0 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:0}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:0}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:22}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:22}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:0},{“num”:22}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:0},{“num”:22}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x04 -> ICONST_1 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:22}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:0},{“num”:22}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:1},{“num”:22}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:1},{“num”:22}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:1},{“num”:84}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:1},{“num”:84}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:1},{“num”:84}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:1},{“num”:84}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x05 -> ICONST_2 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:1},{“num”:84}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:1},{“num”:84}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:2},{“num”:84}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:2},{“num”:84}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:2},{“num”:77}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:2},{“num”:77}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:2},{“num”:77}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:2},{“num”:77}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x06 -> ICONST_3 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:2},{“num”:77}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:2},{“num”:77}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:3},{“num”:77}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:3},{“num”:77}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:3},{“num”:11}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:3},{“num”:11}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:3},{“num”:11}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:3},{“num”:11}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x07 -> ICONST_4 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:3},{“num”:11}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:3},{“num”:11}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:4},{“num”:11}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:4},{“num”:11}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:4},{“num”:95}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:4},{“num”:95}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:4},{“num”:95}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:4},{“num”:95}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x08 -> ICONST_5 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:4},{“num”:95}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:4},{“num”:95}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:5},{“num”:95}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:5},{“num”:95}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:5},{“num”:9}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:5},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:5},{“num”:9}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:5},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:5},{“num”:9}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:5},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:6},{“num”:9}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:6},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:6},{“num”:78}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:6},{“num”:78}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:6},{“num”:78}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:6},{“num”:78}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:6},{“num”:78}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:6},{“num”:78}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:7},{“num”:78}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:7},{“num”:78}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:7},{“num”:56}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:7},{“num”:56}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:7},{“num”:56}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:7},{“num”:56}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:7},{“num”:56}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:7},{“num”:56}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:8},{“num”:56}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:8},{“num”:56}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:8},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:8},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:8},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:8},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:8},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:8},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:9},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:9},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:9},{“num”:97}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:9},{“num”:97}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:9},{“num”:97}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:9},{“num”:97}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:9},{“num”:97}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:9},{“num”:97}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:10},{“num”:97}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:10},{“num”:97}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:10},{“num”:65}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:10},{“num”:65}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:10},{“num”:65}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:10},{“num”:65}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:10},{“num”:65}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:10},{“num”:65}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:11},{“num”:65}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:11},{“num”:65}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:11},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:11},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:11},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:11},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:11},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:11},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:12},{“num”:36}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:12},{“num”:36}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:12},{“num”:10}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:12},{“num”:10}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:12},{“num”:10}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:12},{“num”:10}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:12},{“num”:10}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:12},{“num”:10}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:13},{“num”:10}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:13},{“num”:10}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:13},{“num”:24}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:13},{“num”:24}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:13},{“num”:24}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:13},{“num”:24}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:13},{“num”:24}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:13},{“num”:24}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:14},{“num”:24}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:14},{“num”:24}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:14},{“num”:92}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:14},{“num”:92}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x59 -> DUP => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:14},{“num”:92}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:14},{“num”:92}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:14},{“num”:92}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:14},{“num”:92}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x10 -> BIPUSH => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:15},{“num”:92}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:15},{“num”:92}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4f -> IASTORE => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:15},{“num”:48}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16,“ref”:{“ r e f " : " ref":" ref":"[0].ref”}},{“num”:15},{“num”:48}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x4c -> ASTORE_1 => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:15},{“num”:48}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:15},{“num”:48}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0x2b -> ALOAD_1 => 局部变量表:[{“num”:16},{“num”:16},{“num”:15},{“num”:48}] 操作数栈:[{“num”:16},{“num”:16},{“num”:15},{“num”:48}]

org/itstack/demo/test/BubbleSortTest.main() 寄存器(指令):0xb8 -> INVOKE_STATIC => 局部变量表:[{“num”:16,“ref”:{}},{“num”:16},{“num”:15},{“num”:48}] 操作数栈:[{“num”:16,“ref”:{}},{“num”:16},{“num”:15},{“num”:48}]

java/lang/Object.() 寄存器(指令):0xb8 -> INVOKE_STATIC => 局部变量表:null 操作数栈:null

java/lang/Object.() 寄存器(指令):0xb1 -> RETURN => 局部变量表:null 操作数栈:null

… …

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xb2 -> GET_STATIC => 局部变量表:[{“num”:9},{“num”:0}] 操作数栈:[{“num”:9},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x15 -> ILOAD => 局部变量表:[{“num”:9},{“num”:0}] 操作数栈:[{“num”:9},{“num”:0}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xb6 -> INVOKE_VIRTUAL => 局部变量表:[{“num”:9},{“num”:9}] 操作数栈:[{“num”:9},{“num”:9}]

9

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x84 -> IINC => 局部变量表:[{“num”:9},{“num”:9}] 操作数栈:[{“num”:9},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xa7 -> GOTO => 局部变量表:[{“num”:9},{“num”:9}] 操作数栈:[{“num”:9},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x1d -> ILOAD_3 => 局部变量表:[{“num”:9},{“num”:9}] 操作数栈:[{“num”:9},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x1c -> ILOAD_2 => 局部变量表:[{“num”:1},{“num”:9}] 操作数栈:[{“num”:1},{“num”:9}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xa2 -> IF_ICMPGE => 局部变量表:[{“num”:1},{“num”:16}] 操作数栈:[{“num”:1},{“num”:16}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x2b -> ALOAD_1 => 局部变量表:[{“num”:1},{“num”:16}] 操作数栈:[{“num”:1},{“num”:16}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x1d -> ILOAD_3 => 局部变量表:[{“num”:1,“ref”:{}},{“num”:16}] 操作数栈:[{“num”:1,“ref”:{}},{“num”:16}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x2e -> IALOAD => 局部变量表:[{“num”:1,“ref”:{}},{“num”:1}] 操作数栈:[{“num”:1,“ref”:{}},{“num”:1}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x36 -> ISTORE => 局部变量表:[{“num”:10},{“num”:1}] 操作数栈:[{“num”:10},{“num”:1}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xb2 -> GET_STATIC => 局部变量表:[{“num”:10},{“num”:1}] 操作数栈:[{“num”:10},{“num”:1}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x15 -> ILOAD => 局部变量表:[{“num”:10},{“num”:1}] 操作数栈:[{“num”:10},{“num”:1}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xb6 -> INVOKE_VIRTUAL => 局部变量表:[{“num”:10},{“num”:10}] 操作数栈:[{“num”:10},{“num”:10}]

10

11

22

24

36

36

48

56

65

77

78

84

92

95

97

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x84 -> IINC => 局部变量表:[{“num”:97},{“num”:97}] 操作数栈:[{“num”:97},{“num”:97}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xa7 -> GOTO => 局部变量表:[{“num”:97},{“num”:97}] 操作数栈:[{“num”:97},{“num”:97}]

Java核心架构进阶知识点

面试成功其实都是必然发生的事情,因为在此之前我做足了充分的准备工作,不单单是纯粹的刷题,更多的还会去刷一些Java核心架构进阶知识点,比如:JVM、高并发、多线程、缓存、Spring相关、分布式、微服务、RPC、网络、设计模式、MQ、Redis、MySQL、设计模式、负载均衡、算法、数据结构、kafka、ZK、集群等。而这些也全被整理浓缩到了一份pdf——《Java核心架构进阶知识点整理》,全部都是精华中的精华,本着共赢的心态,好东西自然也是要分享的

image

image

image

内容颇多,篇幅却有限,这就不在过多的介绍了,大家可根据以上截图自行脑补

,{“num”:10}] 操作数栈:[{“num”:10},{“num”:10}]

10

11

22

24

36

36

48

56

65

77

78

84

92

95

97

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0x84 -> IINC => 局部变量表:[{“num”:97},{“num”:97}] 操作数栈:[{“num”:97},{“num”:97}]

org/itstack/demo/test/BubbleSortTest.printArray() 寄存器(指令):0xa7 -> GOTO => 局部变量表:[{“num”:97},{“num”:97}] 操作数栈:[{“num”:97},{“num”:97}]

Java核心架构进阶知识点

面试成功其实都是必然发生的事情,因为在此之前我做足了充分的准备工作,不单单是纯粹的刷题,更多的还会去刷一些Java核心架构进阶知识点,比如:JVM、高并发、多线程、缓存、Spring相关、分布式、微服务、RPC、网络、设计模式、MQ、Redis、MySQL、设计模式、负载均衡、算法、数据结构、kafka、ZK、集群等。而这些也全被整理浓缩到了一份pdf——《Java核心架构进阶知识点整理》,全部都是精华中的精华,本着共赢的心态,好东西自然也是要分享的

[外链图片转存中…(img-jDGgGNC7-1714206274585)]

[外链图片转存中…(img-ogtzM2vy-1714206274586)]

[外链图片转存中…(img-nSnfaLy1-1714206274586)]

内容颇多,篇幅却有限,这就不在过多的介绍了,大家可根据以上截图自行脑补

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

  • 26
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值