|
|
@ -148,14 +148,14 @@ public class ConstantPool private constructor( |
|
|
|
strings.remove(LINE_NUMBER_TABLE) |
|
|
|
strings.remove(LINE_NUMBER_TABLE) |
|
|
|
|
|
|
|
|
|
|
|
val it = strings.iterator() |
|
|
|
val it = strings.iterator() |
|
|
|
val stringArray = Array(6 + strings.size) { i -> |
|
|
|
val stringArray = Array(BUILTIN_STRINGS + strings.size) { i -> |
|
|
|
when (i) { |
|
|
|
when (i) { |
|
|
|
0 -> CODE |
|
|
|
CODE_INDEX -> CODE |
|
|
|
1 -> EXCEPTIONS |
|
|
|
EXCEPTIONS_INDEX -> EXCEPTIONS |
|
|
|
2 -> SYNTHETIC |
|
|
|
SYNTHETIC_INDEX -> SYNTHETIC |
|
|
|
3 -> CONSTANT_VALUE |
|
|
|
CONSTANT_VALUE_INDEX -> CONSTANT_VALUE |
|
|
|
4 -> SOURCE_FILE |
|
|
|
SOURCE_FILE_INDEX -> SOURCE_FILE |
|
|
|
5 -> LINE_NUMBER_TABLE |
|
|
|
LINE_NUMBER_TABLE_INDEX -> LINE_NUMBER_TABLE |
|
|
|
else -> it.next() |
|
|
|
else -> it.next() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -184,13 +184,13 @@ public class ConstantPool private constructor( |
|
|
|
|
|
|
|
|
|
|
|
private fun getStringIndex(value: String): Int { |
|
|
|
private fun getStringIndex(value: String): Int { |
|
|
|
return when (value) { |
|
|
|
return when (value) { |
|
|
|
CODE -> 0 |
|
|
|
CODE -> CODE_INDEX |
|
|
|
EXCEPTIONS -> 1 |
|
|
|
EXCEPTIONS -> EXCEPTIONS_INDEX |
|
|
|
SYNTHETIC -> 2 |
|
|
|
SYNTHETIC -> SYNTHETIC_INDEX |
|
|
|
CONSTANT_VALUE -> 3 |
|
|
|
CONSTANT_VALUE -> CONSTANT_VALUE_INDEX |
|
|
|
SOURCE_FILE -> 4 |
|
|
|
SOURCE_FILE -> SOURCE_FILE_INDEX |
|
|
|
LINE_NUMBER_TABLE -> 5 |
|
|
|
LINE_NUMBER_TABLE -> LINE_NUMBER_TABLE_INDEX |
|
|
|
else -> strings.binarySearch(value, 6) |
|
|
|
else -> strings.binarySearch(value, BUILTIN_STRINGS) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -329,7 +329,7 @@ public class ConstantPool private constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun writeStrings(buf: ByteBuf) { |
|
|
|
private fun writeStrings(buf: ByteBuf) { |
|
|
|
for (i in 6 until strings.size) { |
|
|
|
for (i in BUILTIN_STRINGS until strings.size) { |
|
|
|
buf.writeString(strings[i], ModifiedUtf8Charset) |
|
|
|
buf.writeString(strings[i], ModifiedUtf8Charset) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -404,6 +404,15 @@ public class ConstantPool private constructor( |
|
|
|
public const val SOURCE_FILE: String = "SourceFile" |
|
|
|
public const val SOURCE_FILE: String = "SourceFile" |
|
|
|
public const val LINE_NUMBER_TABLE: String = "LineNumberTable" |
|
|
|
public const val LINE_NUMBER_TABLE: String = "LineNumberTable" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public const val CODE_INDEX: Int = 0 |
|
|
|
|
|
|
|
public const val EXCEPTIONS_INDEX: Int = 1 |
|
|
|
|
|
|
|
public const val SYNTHETIC_INDEX: Int = 2 |
|
|
|
|
|
|
|
public const val CONSTANT_VALUE_INDEX: Int = 3 |
|
|
|
|
|
|
|
public const val SOURCE_FILE_INDEX: Int = 4 |
|
|
|
|
|
|
|
public const val LINE_NUMBER_TABLE_INDEX: Int = 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public const val BUILTIN_STRINGS: Int = 6 |
|
|
|
|
|
|
|
|
|
|
|
private const val TRAILER_LEN = 20 |
|
|
|
private const val TRAILER_LEN = 20 |
|
|
|
|
|
|
|
|
|
|
|
public fun read(buf: ByteBuf): ConstantPool { |
|
|
|
public fun read(buf: ByteBuf): ConstantPool { |
|
|
@ -477,16 +486,16 @@ public class ConstantPool private constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun readStrings(buf: ByteBuf, size: Int): Array<String> { |
|
|
|
private fun readStrings(buf: ByteBuf, size: Int): Array<String> { |
|
|
|
require(size >= 6) |
|
|
|
require(size >= BUILTIN_STRINGS) |
|
|
|
|
|
|
|
|
|
|
|
return Array(size) { i -> |
|
|
|
return Array(size) { i -> |
|
|
|
when (i) { |
|
|
|
when (i) { |
|
|
|
0 -> CODE |
|
|
|
CODE_INDEX -> CODE |
|
|
|
1 -> EXCEPTIONS |
|
|
|
EXCEPTIONS_INDEX -> EXCEPTIONS |
|
|
|
2 -> SYNTHETIC |
|
|
|
SYNTHETIC_INDEX -> SYNTHETIC |
|
|
|
3 -> CONSTANT_VALUE |
|
|
|
CONSTANT_VALUE_INDEX -> CONSTANT_VALUE |
|
|
|
4 -> SOURCE_FILE |
|
|
|
SOURCE_FILE_INDEX -> SOURCE_FILE |
|
|
|
5 -> LINE_NUMBER_TABLE |
|
|
|
LINE_NUMBER_TABLE_INDEX -> LINE_NUMBER_TABLE |
|
|
|
else -> buf.readString(ModifiedUtf8Charset) |
|
|
|
else -> buf.readString(ModifiedUtf8Charset) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|