String str; int i, j, k; byte tag = c.getTag();
@Override public void visitConstantPool(ConstantPool obj) { super.visitConstantPool(obj); Constant[] constant_pool = obj.getConstantPool(); for (int i = 1; i < constant_pool.length; i++) { constant_pool[i].accept(this); byte tag = constant_pool[i].getTag(); if ((tag == Const.CONSTANT_Double) || (tag == Const.CONSTANT_Long)) { i++; } } }
/** * Read constants from given file stream. * * @param file Input stream * @throws IOException * @throws ClassFormatException */ ConstantPool(DataInputStream file) throws IOException, ClassFormatException { byte tag; constant_pool_count = file.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for(int i=1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(file); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ tag = constant_pool[i].getTag(); if((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) i++; } }
public void visitConstantPool(ConstantPool cp) { stack.push(cp); cp.accept(visitor); Constant[] constants = cp.getConstantPool(); for(int i=1; i < constants.length; i++) { if(constants[i] != null) constants[i].accept(this); } stack.pop(); }
/** * @return String representation */ @Override public final String toString() { return super.toString() + "(name_index = " + name_index + ", signature_index = " + signature_index + ")"; } }
/** * Dump constant pool to file stream in binary format. * * @param file Output file stream * @throws IOException */ public void dump(DataOutputStream file) throws IOException { file.writeShort(constant_pool_count); for(int i=1; i < constant_pool_count; i++) if(constant_pool[i] != null) constant_pool[i].dump(file); }
/** * @return deep copy of this constant pool */ public ConstantPool copy() { ConstantPool c = null; try { c = (ConstantPool)clone(); } catch(CloneNotSupportedException e) {} c.constant_pool = new Constant[constant_pool_count]; for(int i=1; i < constant_pool_count; i++) { if(constant_pool[i] != null) c.constant_pool[i] = constant_pool[i].copy(); } return c; } }
/** * Read constants from given input stream. * * @param input Input stream * @throws IOException * @throws ClassFormatException */ public ConstantPool(final DataInput input) throws IOException, ClassFormatException { byte tag; final int constant_pool_count = input.readUnsignedShort(); constant_pool = new Constant[constant_pool_count]; /* constant_pool[0] is unused by the compiler and may be used freely * by the implementation. */ for (int i = 1; i < constant_pool_count; i++) { constant_pool[i] = Constant.readConstant(input); /* Quote from the JVM specification: * "All eight byte constants take up two spots in the constant pool. * If this is the n'th byte in the constant pool, then the next item * will be numbered n+2" * * Thus we have to increment the index counter. */ tag = constant_pool[i].getTag(); if ((tag == Const.CONSTANT_Double) || (tag == Const.CONSTANT_Long)) { i++; } } }
@Override public void visitConstantPool(final ConstantPool cp) { stack.push(cp); cp.accept(visitor); final Constant[] constants = cp.getConstantPool(); for (int i = 1; i < constants.length; i++) { if (constants[i] != null) { constants[i].accept(this); } } stack.pop(); }
/** * @return String representation. */ @Override public final String toString() { return super.toString() + "(name_index = " + name_index + ")"; } }
/** * Dump constant pool to file stream in binary format. * * @param file Output file stream * @throws IOException */ public void dump( final DataOutputStream file ) throws IOException { file.writeShort(constant_pool.length); for (int i = 1; i < constant_pool.length; i++) { if (constant_pool[i] != null) { constant_pool[i].dump(file); } } }
/** * @return deep copy of this constant pool */ public ConstantPool copy() { ConstantPool c = null; try { c = (ConstantPool) clone(); c.constant_pool = new Constant[constant_pool.length]; for (int i = 1; i < constant_pool.length; i++) { if (constant_pool[i] != null) { c.constant_pool[i] = constant_pool[i].copy(); } } } catch (final CloneNotSupportedException e) { // TODO should this throw? } return c; } }
/** * Dump constant package to file stream in binary format. * * @param file Output file stream * @throws IOException */ @Override public final void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); file.writeShort(name_index); }
@Override public void visitConstantPool(ConstantPool obj) { super.visitConstantPool(obj); Constant[] constant_pool = obj.getConstantPool(); for (int i = 1; i < constant_pool.length; i++) { constant_pool[i].accept(this); byte tag = constant_pool[i].getTag(); if ((tag == CONSTANT_Double) || (tag == CONSTANT_Long)) { i++; } } }
c.accept(new EmptyVisitor()
/** * @return String representation. */ public final String toString() { return super.toString() + "(bytes = " + bytes + ")"; }
/** * Dump String in Utf8 format to file stream. * * @param file Output file stream * @throws IOException */ @Override public final void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); file.writeUTF(bytes); }
@Override public void visitJavaClass(JavaClass obj) { current = javaClassDao.getJavaClass(obj.getClassName()); int major = obj.getMajor(); int minor = obj.getMinor(); current.setMajorVersion(major); current.setMinorVersion(minor); current.addResource(resource); current.setPackageName(obj.getPackageName()); for (String interfaceName : obj.getInterfaceNames()) { org.jboss.windup.graph.model.resource.JavaClass interfaceClass = javaClassDao.getJavaClass(interfaceName); // then we make the connection. current.addImplements(interfaceClass); } // process the pool. Constant[] pool = obj.getConstantPool().getConstantPool(); for (Constant c : pool) { if (c == null) continue; c.accept(this); } String superClz = obj.getSuperclassName(); org.jboss.windup.graph.model.resource.JavaClass superJavaClass = javaClassDao.getJavaClass(superClz); current.setExtends(superJavaClass); }
/** * @return String representation. * * not final as ConstantInvokeDynamic needs to modify */ @Override public String toString() { return super.toString() + "(class_index = " + class_index + ", name_and_type_index = " + name_and_type_index + ")"; } }
/** * Dump constant field reference to file stream in binary format. * * @param file Output file stream * @throws IOException */ @Override public final void dump( final DataOutputStream file ) throws IOException { file.writeByte(super.getTag()); file.writeShort(string_index); }