diff options
author | Jean-Philippe Lesot <jplesot@google.com> | 2013-05-17 07:26:19 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-05-17 07:26:20 +0000 |
commit | 97208a0be35a4b9583172dc853150a32bb138f15 (patch) | |
tree | 82ad444684cec09d06af862d40d051249a61ab81 /dx/src/com/android/dx | |
parent | 467f7e3aaf8aafe324744bfd825fe9941862b7b7 (diff) | |
parent | 5ca383d7373cf7c54706b8e70d534deee8d2e3ad (diff) | |
download | android_dalvik-97208a0be35a4b9583172dc853150a32bb138f15.tar.gz android_dalvik-97208a0be35a4b9583172dc853150a32bb138f15.tar.bz2 android_dalvik-97208a0be35a4b9583172dc853150a32bb138f15.zip |
Merge "Added support for version 51 class files in dx"
Diffstat (limited to 'dx/src/com/android/dx')
-rw-r--r-- | dx/src/com/android/dx/cf/code/ByteOps.java | 1 | ||||
-rw-r--r-- | dx/src/com/android/dx/cf/code/BytecodeArray.java | 4 | ||||
-rw-r--r-- | dx/src/com/android/dx/cf/cst/ConstantPoolParser.java | 93 | ||||
-rw-r--r-- | dx/src/com/android/dx/cf/cst/ConstantTags.java | 9 | ||||
-rw-r--r-- | dx/src/com/android/dx/cf/direct/DirectClassFile.java | 3 |
5 files changed, 75 insertions, 35 deletions
diff --git a/dx/src/com/android/dx/cf/code/ByteOps.java b/dx/src/com/android/dx/cf/code/ByteOps.java index 13760088c..850346a94 100644 --- a/dx/src/com/android/dx/cf/code/ByteOps.java +++ b/dx/src/com/android/dx/cf/code/ByteOps.java @@ -210,6 +210,7 @@ public class ByteOps { public static final int INVOKESPECIAL = 0xb7; public static final int INVOKESTATIC = 0xb8; public static final int INVOKEINTERFACE = 0xb9; + public static final int INVOKEDYNAMIC = 0xba; public static final int NEW = 0xbb; public static final int NEWARRAY = 0xbc; public static final int ANEWARRAY = 0xbd; diff --git a/dx/src/com/android/dx/cf/code/BytecodeArray.java b/dx/src/com/android/dx/cf/code/BytecodeArray.java index f4ea007b9..424b971a8 100644 --- a/dx/src/com/android/dx/cf/code/BytecodeArray.java +++ b/dx/src/com/android/dx/cf/code/BytecodeArray.java @@ -16,6 +16,7 @@ package com.android.dx.cf.code; +import com.android.dx.cf.iface.ParseException; import com.android.dx.rop.cst.Constant; import com.android.dx.rop.cst.ConstantPool; import com.android.dx.rop.cst.CstDouble; @@ -772,6 +773,9 @@ public final class BytecodeArray { count | (expectZero << 8)); return 5; } + case ByteOps.INVOKEDYNAMIC: { + throw new ParseException("invokedynamic not supported"); + } case ByteOps.NEWARRAY: { return parseNewarray(offset, visitor); } diff --git a/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java b/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java index 7ec2fbac0..036c8802a 100644 --- a/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java +++ b/dx/src/com/android/dx/cf/cst/ConstantPoolParser.java @@ -27,6 +27,9 @@ import static com.android.dx.cf.cst.ConstantTags.CONSTANT_Methodref; import static com.android.dx.cf.cst.ConstantTags.CONSTANT_NameAndType; import static com.android.dx.cf.cst.ConstantTags.CONSTANT_String; import static com.android.dx.cf.cst.ConstantTags.CONSTANT_Utf8; +import static com.android.dx.cf.cst.ConstantTags.CONSTANT_MethodHandle; +import static com.android.dx.cf.cst.ConstantTags.CONSTANT_MethodType; +import static com.android.dx.cf.cst.ConstantTags.CONSTANT_InvokeDynamic; import com.android.dx.cf.iface.ParseException; import com.android.dx.cf.iface.ParseObserver; import com.android.dx.rop.cst.Constant; @@ -184,41 +187,51 @@ public final class ConstantPoolParser { for (int i = 1; i < offsets.length; i += lastCategory) { offsets[i] = at; int tag = bytes.getUnsignedByte(at); - switch (tag) { - case CONSTANT_Integer: - case CONSTANT_Float: - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - case CONSTANT_NameAndType: { - lastCategory = 1; - at += 5; - break; - } - case CONSTANT_Long: - case CONSTANT_Double: { - lastCategory = 2; - at += 9; - break; - } - case CONSTANT_Class: - case CONSTANT_String: { - lastCategory = 1; - at += 3; - break; - } - case CONSTANT_Utf8: { - lastCategory = 1; - at += bytes.getUnsignedShort(at + 1) + 3; - break; - } - default: { - ParseException ex = - new ParseException("unknown tag byte: " + Hex.u1(tag)); - ex.addContext("...while preparsing cst " + Hex.u2(i) + - " at offset " + Hex.u4(at)); - throw ex; + try { + switch (tag) { + case CONSTANT_Integer: + case CONSTANT_Float: + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + case CONSTANT_NameAndType: { + lastCategory = 1; + at += 5; + break; + } + case CONSTANT_Long: + case CONSTANT_Double: { + lastCategory = 2; + at += 9; + break; + } + case CONSTANT_Class: + case CONSTANT_String: { + lastCategory = 1; + at += 3; + break; + } + case CONSTANT_Utf8: { + lastCategory = 1; + at += bytes.getUnsignedShort(at + 1) + 3; + break; + } + case CONSTANT_MethodHandle: { + throw new ParseException("MethodHandle not supported"); + } + case CONSTANT_MethodType: { + throw new ParseException("MethodType not supported"); + } + case CONSTANT_InvokeDynamic: { + throw new ParseException("InvokeDynamic not supported"); + } + default: { + throw new ParseException("unknown tag byte: " + Hex.u1(tag)); + } } + } catch (ParseException ex) { + ex.addContext("...while preparsing cst " + Hex.u2(i) + " at offset " + Hex.u4(at)); + throw ex; } } @@ -313,6 +326,18 @@ public final class ConstantPoolParser { cst = new CstNat(name, descriptor); break; } + case CONSTANT_MethodHandle: { + throw new ParseException("MethodHandle not supported"); + } + case CONSTANT_MethodType: { + throw new ParseException("MethodType not supported"); + } + case CONSTANT_InvokeDynamic: { + throw new ParseException("InvokeDynamic not supported"); + } + default: { + throw new ParseException("unknown tag byte: " + Hex.u1(tag)); + } } } catch (ParseException ex) { ex.addContext("...while parsing cst " + Hex.u2(idx) + diff --git a/dx/src/com/android/dx/cf/cst/ConstantTags.java b/dx/src/com/android/dx/cf/cst/ConstantTags.java index 9febbdf5e..56ef4d75f 100644 --- a/dx/src/com/android/dx/cf/cst/ConstantTags.java +++ b/dx/src/com/android/dx/cf/cst/ConstantTags.java @@ -52,4 +52,13 @@ public interface ConstantTags { /** tag for a {@code CONSTANT_NameAndType_info} */ int CONSTANT_NameAndType = 12; + + /** tag for a {@code CONSTANT_MethodHandle} */ + int CONSTANT_MethodHandle = 15; + + /** tag for a {@code CONSTANT_MethodType} */ + int CONSTANT_MethodType = 16; + + /** tag for a {@code CONSTANT_InvokeDynamic} */ + int CONSTANT_InvokeDynamic = 18; } diff --git a/dx/src/com/android/dx/cf/direct/DirectClassFile.java b/dx/src/com/android/dx/cf/direct/DirectClassFile.java index a7bb073a6..2af2efe68 100644 --- a/dx/src/com/android/dx/cf/direct/DirectClassFile.java +++ b/dx/src/com/android/dx/cf/direct/DirectClassFile.java @@ -50,6 +50,7 @@ public class DirectClassFile implements ClassFile { * See http://en.wikipedia.org/wiki/Java_class_file for an up-to-date * list of version numbers. Currently known (taken from that table) are: * + * J2SE 7.0 = 51 (0x33 hex), * J2SE 6.0 = 50 (0x32 hex), * J2SE 5.0 = 49 (0x31 hex), * JDK 1.4 = 48 (0x30 hex), @@ -68,7 +69,7 @@ public class DirectClassFile implements ClassFile { * * Note: if you change this, please change "java.class.version" in System.java. */ - private static final int CLASS_FILE_MAX_MAJOR_VERSION = 50; + private static final int CLASS_FILE_MAX_MAJOR_VERSION = 51; /** maximum {@code .class} file minor version */ private static final int CLASS_FILE_MAX_MINOR_VERSION = 0; |