本文整理汇总了Java中java.io.DataInput.readUnsignedShort方法的典型用法代码示例。如果您正苦于以下问题:Java DataInput.readUnsignedShort方法的具体用法?Java DataInput.readUnsignedShort怎么用?Java DataInput.readUnsignedShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataInput
的用法示例。
在下文中一共展示了DataInput.readUnsignedShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readArrayLength
import java.io.DataInput; //导入方法依赖的package包/类
public static int readArrayLength(DataInput in) throws IOException {
byte code = in.readByte();
if (code == NULL_ARRAY) {
return -1;
} else {
int result = ubyteToInt(code);
if (result > MAX_BYTE_ARRAY_LEN) {
if (code == SHORT_ARRAY_LEN) {
result = in.readUnsignedShort();
} else if (code == INT_ARRAY_LEN) {
result = in.readInt();
} else {
throw new IllegalStateException("unexpected array length code=" + code);
}
}
return result;
}
}
示例2: readModuleResolution
import java.io.DataInput; //导入方法依赖的package包/类
/**
* Reads the ModuleResolution attribute.
*/
private ModuleResolution readModuleResolution(DataInput in,
ConstantPool cpool)
throws IOException
{
int flags = in.readUnsignedShort();
int reason = 0;
if ((flags & WARN_DEPRECATED) != 0)
reason = WARN_DEPRECATED;
if ((flags & WARN_DEPRECATED_FOR_REMOVAL) != 0) {
if (reason != 0)
throw invalidModuleDescriptor("Bad module resolution flags:" + flags);
reason = WARN_DEPRECATED_FOR_REMOVAL;
}
if ((flags & WARN_INCUBATING) != 0) {
if (reason != 0)
throw invalidModuleDescriptor("Bad module resolution flags:" + flags);
}
return new ModuleResolution(flags);
}
示例3: testReadUnsignedShort_eof
import java.io.DataInput; //导入方法依赖的package包/类
public void testReadUnsignedShort_eof() throws IOException {
byte[] buf = {23};
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf));
try {
in.readUnsignedShort();
fail();
} catch (EOFException expected) {}
}
示例4: parseMethods
import java.io.DataInput; //导入方法依赖的package包/类
private BytecodeMethod[] parseMethods(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
List<BytecodeMethod> theMethods = new ArrayList<>();
int theMethodCount = aDis.readUnsignedShort();
for (int i=0;i<theMethodCount;i++) {
int theAccessFlags = aDis.readUnsignedShort();
int theNameIndex = aDis.readUnsignedShort();
BytecodeConstant theName = aConstantPool.constantByIndex(theNameIndex - 1);
if (!(theName instanceof BytecodeUtf8Constant)) {
throw new IllegalStateException("Invalid interface constant reference : got type " + theName.getClass().getName());
}
int theDescriptorIndex = aDis.readUnsignedShort();
BytecodeConstant theDescriptor = aConstantPool.constantByIndex(theDescriptorIndex - 1);
if (!(theDescriptor instanceof BytecodeUtf8Constant)) {
throw new IllegalStateException("Invalid interface constant reference : got type " + theDescriptor.getClass().getName());
}
BytecodeAttributeInfo[] theAttributes = parseAttributes(aDis, aConstantPool);
theMethods.add(new BytecodeMethod(new BytecodeAccessFlags(theAccessFlags),
(BytecodeUtf8Constant) theName,
signatureParser.toMethodSignature((BytecodeUtf8Constant) theDescriptor),
theAttributes));
}
return theMethods.toArray(new BytecodeMethod[theMethods.size()]);
}
示例5: AnnotationEntry
import java.io.DataInput; //导入方法依赖的package包/类
AnnotationEntry(final DataInput input, final ConstantPool constant_pool) throws IOException {
this.constant_pool = constant_pool;
type_index = input.readUnsignedShort();
final int num_element_value_pairs = input.readUnsignedShort();
element_value_pairs = new ArrayList<ElementValuePair>(num_element_value_pairs);
for (int i = 0; i < num_element_value_pairs; i++) {
element_value_pairs.add(new ElementValuePair(input, constant_pool));
}
}
示例6: read
import java.io.DataInput; //导入方法依赖的package包/类
public static AnnotationEntryGen read(final DataInput dis,
final ConstantPoolGen cpool, final boolean b) throws IOException {
final AnnotationEntryGen a = new AnnotationEntryGen(cpool);
a.typeIndex = dis.readUnsignedShort();
final int elemValuePairCount = dis.readUnsignedShort();
for (int i = 0; i < elemValuePairCount; i++) {
final int nidx = dis.readUnsignedShort();
a.addElementNameValuePair(new ElementValuePairGen(nidx,
ElementValueGen.readElementValue(dis, cpool), cpool));
}
a.isRuntimeVisible(b);
return a;
}
示例7: LocalVariableTable
import java.io.DataInput; //导入方法依赖的package包/类
/**
* Construct object from input stream.
* @param name_index Index in constant pool
* @param length Content length in bytes
* @param input Input stream
* @param constant_pool Array of constants
* @throws IOException
*/
LocalVariableTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
throws IOException {
this(name_index, length, (LocalVariable[]) null, constant_pool);
final int local_variable_table_length = input.readUnsignedShort();
local_variable_table = new LocalVariable[local_variable_table_length];
for (int i = 0; i < local_variable_table_length; i++) {
local_variable_table[i] = new LocalVariable(input, constant_pool);
}
}
示例8: parseBootstrapAttribute
import java.io.DataInput; //导入方法依赖的package包/类
private BytecodeBootstrapMethodsAttributeInfo parseBootstrapAttribute(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
int theNumMethods = aDis.readUnsignedShort();
List<BytecodeBootstrapMethod> theMethods = new ArrayList<>();
for (int i=0;i<theNumMethods;i++) {
int theMethodRef = aDis.readUnsignedShort();
int theNumArguments = aDis.readUnsignedShort();
int[] theArguments = new int[theNumArguments];
for (int j=0;j<theNumArguments;j++) {
theArguments[j] = aDis.readUnsignedShort();
}
theMethods.add(new BytecodeBootstrapMethod(theMethodRef, theArguments, aConstantPool));
}
return new BytecodeBootstrapMethodsAttributeInfo(theMethods.toArray(new BytecodeBootstrapMethod[theMethods.size()]));
}
示例9: parseConstantPool_CONSTANT_Utf8
import java.io.DataInput; //导入方法依赖的package包/类
private void parseConstantPool_CONSTANT_Utf8(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
int theLength = aDis.readUnsignedShort();
byte[] theData = new byte[theLength];
aDis.readFully(theData);
aConstantPool.registerConstant(new BytecodeUtf8Constant(new String(theData, "UTF-8")));
}
示例10: ElementValuePair
import java.io.DataInput; //导入方法依赖的package包/类
ElementValuePair(final DataInput file, final ConstantPool constantPool) throws IOException {
this.constantPool = constantPool;
this.elementNameIndex = file.readUnsignedShort();
this.elementValue = ElementValue.readElementValue(file, constantPool);
}
示例11: readVLong
import java.io.DataInput; //导入方法依赖的package包/类
/**
* Decoding the variable-length integer. Suppose the value of the first byte
* is FB, and the following bytes are NB[*].
* <ul>
* <li>if (FB >= -32), return (long)FB;
* <li>if (FB in [-72, -33]), return (FB+52)<<8 + NB[0]&0xff;
* <li>if (FB in [-104, -73]), return (FB+88)<<16 + (NB[0]&0xff)<<8 +
* NB[1]&0xff;
* <li>if (FB in [-120, -105]), return (FB+112)<<24 + (NB[0]&0xff)<<16 +
* (NB[1]&0xff)<<8 + NB[2]&0xff;
* <li>if (FB in [-128, -121]), return interpret NB[FB+129] as a signed
* big-endian integer.
*
* @param in
* input stream
* @return the decoded long integer.
* @throws IOException
*/
public static long readVLong(DataInput in) throws IOException {
int firstByte = in.readByte();
if (firstByte >= -32) {
return firstByte;
}
switch ((firstByte + 128) / 8) {
case 11:
case 10:
case 9:
case 8:
case 7:
return ((firstByte + 52) << 8) | in.readUnsignedByte();
case 6:
case 5:
case 4:
case 3:
return ((firstByte + 88) << 16) | in.readUnsignedShort();
case 2:
case 1:
return ((firstByte + 112) << 24) | (in.readUnsignedShort() << 8)
| in.readUnsignedByte();
case 0:
int len = firstByte + 129;
switch (len) {
case 4:
return in.readInt();
case 5:
return ((long) in.readInt()) << 8 | in.readUnsignedByte();
case 6:
return ((long) in.readInt()) << 16 | in.readUnsignedShort();
case 7:
return ((long) in.readInt()) << 24 | (in.readUnsignedShort() << 8)
| in.readUnsignedByte();
case 8:
return in.readLong();
default:
throw new IOException("Corrupted VLong encoding");
}
default:
throw new RuntimeException("Internal error");
}
}
示例12: readElementValue
import java.io.DataInput; //导入方法依赖的package包/类
public static ElementValueGen readElementValue(final DataInput dis,
final ConstantPoolGen cpGen) throws IOException
{
final int type = dis.readUnsignedByte();
switch (type)
{
case 'B': // byte
return new SimpleElementValueGen(PRIMITIVE_BYTE, dis
.readUnsignedShort(), cpGen);
case 'C': // char
return new SimpleElementValueGen(PRIMITIVE_CHAR, dis
.readUnsignedShort(), cpGen);
case 'D': // double
return new SimpleElementValueGen(PRIMITIVE_DOUBLE, dis
.readUnsignedShort(), cpGen);
case 'F': // float
return new SimpleElementValueGen(PRIMITIVE_FLOAT, dis
.readUnsignedShort(), cpGen);
case 'I': // int
return new SimpleElementValueGen(PRIMITIVE_INT, dis
.readUnsignedShort(), cpGen);
case 'J': // long
return new SimpleElementValueGen(PRIMITIVE_LONG, dis
.readUnsignedShort(), cpGen);
case 'S': // short
return new SimpleElementValueGen(PRIMITIVE_SHORT, dis
.readUnsignedShort(), cpGen);
case 'Z': // boolean
return new SimpleElementValueGen(PRIMITIVE_BOOLEAN, dis
.readUnsignedShort(), cpGen);
case 's': // String
return new SimpleElementValueGen(STRING, dis.readUnsignedShort(),
cpGen);
case 'e': // Enum constant
return new EnumElementValueGen(dis.readUnsignedShort(), dis
.readUnsignedShort(), cpGen);
case 'c': // Class
return new ClassElementValueGen(dis.readUnsignedShort(), cpGen);
case '@': // Annotation
// TODO: isRuntimeVisible ??????????
// FIXME
return new AnnotationElementValueGen(ANNOTATION,
new AnnotationEntryGen(AnnotationEntry.read(dis, cpGen
.getConstantPool(), true), cpGen, false), cpGen);
case '[': // Array
final int numArrayVals = dis.readUnsignedShort();
final ElementValue[] evalues = new ElementValue[numArrayVals];
for (int j = 0; j < numArrayVals; j++)
{
evalues[j] = ElementValue.readElementValue(dis, cpGen
.getConstantPool());
}
return new ArrayElementValueGen(ARRAY, evalues, cpGen);
default:
throw new RuntimeException("Unexpected element value kind in annotation: " + type);
}
}
示例13: parseConstantPool_CONSTANT_Class
import java.io.DataInput; //导入方法依赖的package包/类
private void parseConstantPool_CONSTANT_Class(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
int theNameIndex = aDis.readUnsignedShort();
aConstantPool.registerConstant(new BytecodeClassinfoConstant(theNameIndex, aConstantPool, packageReplacer));
}
示例14: parseConstantPool_CONSTANT_Fieldref
import java.io.DataInput; //导入方法依赖的package包/类
private void parseConstantPool_CONSTANT_Fieldref(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
int theClassIndex = aDis.readUnsignedShort();
int theNameAndTypeIndex = aDis.readUnsignedShort();
aConstantPool.registerConstant(new BytecodeFieldRefConstant(new BytecodeClassIndex(theClassIndex, aConstantPool), new BytecodeNameAndTypeIndex(theNameAndTypeIndex, aConstantPool)));
}
示例15: parseConstantPool_CONSTANT_Methodref
import java.io.DataInput; //导入方法依赖的package包/类
private void parseConstantPool_CONSTANT_Methodref(DataInput aDis, BytecodeConstantPool aConstantPool) throws IOException {
int theClassIndex = aDis.readUnsignedShort();
int theNameAndTypeIndex = aDis.readUnsignedShort();
aConstantPool.registerConstant(new BytecodeMethodRefConstant(new BytecodeClassIndex(theClassIndex, aConstantPool), new BytecodeNameAndTypeIndex(theNameAndTypeIndex, aConstantPool)));
}