use of javassist.bytecode.BadBytecode in project javassist by jboss-javassist.
the class MapMaker method make2.
/**
* Computes the stack map table for J2ME.
* It returns null if the given method does not have to have a
* stack map table or it includes JSR.
*/
public static StackMap make2(ClassPool classes, MethodInfo minfo) throws BadBytecode {
CodeAttribute ca = minfo.getCodeAttribute();
if (ca == null)
return null;
TypedBlock[] blocks;
try {
blocks = TypedBlock.makeBlocks(minfo, ca, true);
} catch (BasicBlock.JsrBytecode e) {
return null;
}
if (blocks == null)
return null;
MapMaker mm = new MapMaker(classes, minfo, ca);
try {
mm.make(blocks, ca.getCode());
} catch (BadBytecode bb) {
throw new BadBytecode(minfo, bb);
}
return mm.toStackMap2(minfo.getConstPool(), blocks);
}
use of javassist.bytecode.BadBytecode in project blaze-persistence by Blazebit.
the class AssignmentAnalyzer method analyzeNextEntry.
private void analyzeNextEntry(MethodInfo method, CodeIterator iter, IntQueue queue, Executor executor) throws BadBytecode {
int pos = queue.take();
iter.move(pos);
iter.next();
Frame frame = frames[pos].copy();
Subroutine subroutine = subroutines[pos];
try {
executor.execute(method, pos, iter, frame, subroutine);
} catch (RuntimeException e) {
throw new BadBytecode(e.getMessage() + "[pos = " + pos + "]", e);
}
int opcode = iter.byteAt(pos);
if (opcode == TABLESWITCH) {
mergeTableSwitch(queue, pos, iter, frame);
} else if (opcode == LOOKUPSWITCH) {
mergeLookupSwitch(queue, pos, iter, frame);
} else if (opcode == RET) {
mergeRet(queue, iter, pos, frame, subroutine);
} else if (Util.isJumpInstruction(opcode)) {
int target = Util.getJumpTarget(pos, iter);
if (Util.isJsr(opcode)) {
// Merge the state before the jsr into the next instruction
mergeJsr(queue, frames[pos], subroutines[target], pos, lookAhead(iter, pos));
} else if (!Util.isGoto(opcode)) {
merge(queue, frame, lookAhead(iter, pos));
}
merge(queue, frame, target);
} else if (opcode != ATHROW && !Util.isReturn(opcode)) {
// Can advance to next instruction
merge(queue, frame, lookAhead(iter, pos));
}
// Merge all exceptions that are reachable from this instruction.
// The redundancy is intentional, since the state must be based
// on the current instruction frame.
mergeExceptionHandlers(queue, method, pos, frame);
}
use of javassist.bytecode.BadBytecode in project blaze-persistence by Blazebit.
the class AssignmentAnalyzer method mergeJsr.
private void mergeJsr(IntQueue queue, Frame frame, Subroutine sub, int pos, int next) throws BadBytecode {
if (sub == null)
throw new BadBytecode("No subroutine at jsr target! [pos = " + pos + "]");
Frame old = frames[next];
boolean changed = false;
if (old == null) {
old = frames[next] = frame.copy();
changed = true;
} else {
for (int i = 0; i < frame.localsLength(); i++) {
// Skip everything accessed by a subroutine, mergeRet must handle this
if (!sub.isAccessed(i)) {
Type oldType = old.getLocal(i);
Type newType = frame.getLocal(i);
if (oldType == null) {
old.setLocal(i, newType);
changed = true;
continue;
}
newType = oldType.merge(newType);
// Always set the type, in case a multi-type switched to a standard type.
old.setLocal(i, newType);
if (!newType.equals(oldType) || TypeUtils.popChanged(newType))
changed = true;
}
}
}
if (!old.isJsrMerged()) {
old.setJsrMerged(true);
changed = true;
}
if (changed && old.isRetMerged())
queue.add(next);
}
use of javassist.bytecode.BadBytecode in project blaze-persistence by Blazebit.
the class Executor method evalLDC.
private void evalLDC(int index, Frame frame) throws BadBytecode {
int tag = constPool.getTag(index);
Type type;
switch(tag) {
case ConstPool.CONST_String:
type = STRING_TYPE;
break;
case ConstPool.CONST_Integer:
type = Type.INTEGER;
break;
case ConstPool.CONST_Float:
type = Type.FLOAT;
break;
case ConstPool.CONST_Long:
type = Type.LONG;
break;
case ConstPool.CONST_Double:
type = Type.DOUBLE;
break;
case ConstPool.CONST_Class:
type = CLASS_TYPE;
break;
default:
throw new BadBytecode("bad LDC [pos = " + lastPos + "]: " + tag);
}
simplePush(type, frame);
}
use of javassist.bytecode.BadBytecode in project blaze-persistence by Blazebit.
the class Executor method evalArrayStore.
private void evalArrayStore(Type expectedComponent, Frame frame) throws BadBytecode {
Type value = simplePop(frame);
Type index = frame.pop();
Type array = frame.pop();
if (array == Type.UNINIT) {
verifyAssignable(Type.INTEGER, index);
return;
}
Type component = array.getComponent();
if (component == null)
throw new BadBytecode("Not an array! [pos = " + lastPos + "]: " + component);
component = zeroExtend(component);
verifyAssignable(expectedComponent, component);
verifyAssignable(Type.INTEGER, index);
// // but will throw arraystoreexception
if (expectedComponent == Type.OBJECT) {
verifyAssignable(expectedComponent, value);
} else {
verifyAssignable(component, value);
}
}
Aggregations