mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 23:47:51 +01:00
Parse annotations with arrays
This commit is contained in:
parent
1771ab1f39
commit
d271ac1a2f
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 - 2019 Volker Berlin (i-net software)
|
* Copyright 2017 - 2021 Volker Berlin (i-net software)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -48,8 +48,26 @@ public class Annotations {
|
|||||||
int valuePairCount = input.readUnsignedShort();
|
int valuePairCount = input.readUnsignedShort();
|
||||||
for( int p = 0; p < valuePairCount; p++ ) {
|
for( int p = 0; p < valuePairCount; p++ ) {
|
||||||
String key = (String)constantPool.get( input.readUnsignedShort() );
|
String key = (String)constantPool.get( input.readUnsignedShort() );
|
||||||
|
Object value = readElementValue( input, constantPool );
|
||||||
|
valuePairs.put( key, value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a single element value
|
||||||
|
*
|
||||||
|
* @param input
|
||||||
|
* the stream of the RuntimeInvisibleAnnotations attribute
|
||||||
|
* @param constantPool
|
||||||
|
* the ConstantPool of the class
|
||||||
|
* @return the value
|
||||||
|
* @throws IOException
|
||||||
|
* if an I/O error occurs
|
||||||
|
*/
|
||||||
|
private static Object readElementValue( DataInputStream input, ConstantPool constantPool ) throws IOException {
|
||||||
int type = input.readUnsignedByte();
|
int type = input.readUnsignedByte();
|
||||||
Object value;
|
|
||||||
switch( type ) {
|
switch( type ) {
|
||||||
case 'B':
|
case 'B':
|
||||||
case 'C':
|
case 'C':
|
||||||
@ -60,15 +78,17 @@ public class Annotations {
|
|||||||
case 'S':
|
case 'S':
|
||||||
case 'Z':
|
case 'Z':
|
||||||
case 's':
|
case 's':
|
||||||
value = constantPool.get( input.readUnsignedShort() );
|
return constantPool.get( input.readUnsignedShort() );
|
||||||
break;
|
case '[':
|
||||||
|
int count = input.readUnsignedShort();
|
||||||
|
Object[] values = new Object[count];
|
||||||
|
for( int i = 0; i < count; i++ ) {
|
||||||
|
values[i] = readElementValue( input, constantPool );
|
||||||
|
}
|
||||||
|
return values;
|
||||||
default:
|
default:
|
||||||
// TODO other possible values for type: e c @ [
|
// TODO other possible values for type: e c @
|
||||||
throw new IOException( "Unknown annotation value type pool type: " + type );
|
throw new IOException( "Unknown annotation value type pool type: " + type );
|
||||||
}
|
}
|
||||||
valuePairs.put( key, value );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return annotations;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user