List of usage examples for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants StringTag
int StringTag
To view the source code for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants StringTag.
Click Source Link
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.BytecodeTransformer.java
License:Open Source License
/** * When copying a team constructor which might require lifting, * peek into the byte code to find the self call. * @param model/*www. ja v a 2 s .c o m*/ * @return called constructor or null */ public MethodBinding peekConstructorCall(TeamModel teamModel, MethodModel model, LookupEnvironment environment) { byte[] bytes = model.getBytes(); int offset = model.getStructOffset(); this._reader = new ConstantPoolObjectReader(model, teamModel, environment); int codeAttributeOffset = findCodeAttribute(bytes, offset); int start = codeAttributeOffset + CODE_ATTR_PREFIX_LEN; int i = 0; while (true) { byte b_int = bytes[start + i]; int length = OTByteCodes.cpReferenceLength(b_int); if (length != 0) { int ref = OTByteCodes.getRef(length, bytes, start + i + 1); ConstantPoolObject src_cpo = this._reader.readConstantPoolObject(ref, length); if (!src_cpo.isMethod() || !src_cpo.getMethodRef().isConstructor()) { if (src_cpo.isSpecificType(TypeConstants.JAVA_LANG_ERROR)) { try { // search subsequent string b_int = bytes[start + i + 4]; length = OTByteCodes.cpReferenceLength(b_int); src_cpo = this._reader.readConstantPoolObject( OTByteCodes.getRef(length, bytes, start + i + 5), length); if (src_cpo.getType() == ClassFileConstants.StringTag) if (src_cpo.getString().startsWith("Unresolved compilation problem:")) //$NON-NLS-1$ model.getBinding().bytecodeMissing = true; // signal that byte code is not usable due to compile error } catch (Throwable t) { // nop, string not found } } return null; } return src_cpo.getMethodRef(); } else if (OTByteCodes.getAloadPos(b_int, bytes[start + i + 1]) != i && b_int != Opcodes.OPC_aconst_null) return null; i++; } }
From source file:org.springframework.ide.eclipse.core.java.typehierarchy.BytecodeTypeHierarchyClassReader.java
License:Open Source License
public TypeHierarchyElement readTypeHierarchy(InputStream stream) { try {//w w w . j a va 2s . c o m DataInputStream dis = new DataInputStream(new BufferedInputStream(stream)); int magic = dis.readInt(); // magic 0xCAFEBABE if (magic != 0xCAFEBABE) { throw new IllegalStateException("not bytecode, magic was 0x" + Integer.toString(magic, 16)); } skip(dis, 4); int constantPoolCount = dis.readShort(); Object[] constantPoolData = new Object[constantPoolCount]; for (int i = 1; i < constantPoolCount; i++) { int tag = dis.readByte(); switch (tag) { case ClassFileConstants.Utf8Tag: constantPoolData[i] = dis.readUTF(); break; case ClassFileConstants.IntegerTag: skip(dis, 4); break; case ClassFileConstants.FloatTag: skip(dis, 4); break; case ClassFileConstants.LongTag: skip(dis, 8); i++; break; case ClassFileConstants.DoubleTag: skip(dis, 8); i++; break; case ClassFileConstants.ClassTag: constantPoolData[i] = dis.readShort(); break; case ClassFileConstants.StringTag: skip(dis, 2); break; case ClassFileConstants.FieldRefTag: skip(dis, 4); break; case ClassFileConstants.MethodRefTag: skip(dis, 4); break; case ClassFileConstants.InterfaceMethodRefTag: skip(dis, 4); break; case ClassFileConstants.NameAndTypeTag: skip(dis, 4); break; case 15: // ClassFileConstants.MethodHandleTag skip(dis, 3); break; case 16: // ClassFileConstants.MethodTypeTag skip(dis, 2); break; case 18: // ClassFileConstants.InvokeDynamicTag skip(dis, 4); break; } } skip(dis, 2); // classname short classNameIndex = dis.readShort(); short classNameUTF8index = (Short) constantPoolData[classNameIndex]; char[] className = ((String) constantPoolData[classNameUTF8index]).toCharArray(); // superclass name short superclassNameIndex = dis.readShort(); char[] superclassName = null; if (superclassNameIndex != 0) { short superclassNameUTF8index = (Short) constantPoolData[superclassNameIndex]; superclassName = ((String) constantPoolData[superclassNameUTF8index]).toCharArray(); } // interfaces short interfacesCount = dis.readShort(); char[][] interfaceNames = null; if (interfacesCount != 0) { interfaceNames = new char[interfacesCount][]; for (int i = 0; i < interfacesCount; i++) { short interfaceNameIndex = dis.readShort(); short interfaceNameUTF8index = (Short) constantPoolData[interfaceNameIndex]; interfaceNames[i] = ((String) constantPoolData[interfaceNameUTF8index]).toCharArray(); } } return new TypeHierarchyElement(className, superclassName, interfaceNames); } catch (Exception e) { SpringCore.log(e); } return null; }