author | jjg |
Mon, 25 Nov 2013 17:42:28 -0800 | |
changeset 21894 | 3535c1819067 |
parent 16854 | 9371f5046d02 |
child 27565 | 729f9700483a |
permissions | -rw-r--r-- |
16854
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
1 |
/* |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
4 |
* |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
8 |
* |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
13 |
* accompanied this code). |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
14 |
* |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
18 |
* |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
21 |
* questions. |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
22 |
*/ |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
23 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
24 |
/* |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
25 |
* @test |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
26 |
* @bug 8011805 |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
27 |
* @summary Update sun.tools.java class file reading/writing support to include the new constant pool entries (including invokedynamic) |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
28 |
*/ |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
29 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
30 |
import java.io.DataInputStream; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
31 |
import java.io.EOFException; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
32 |
import java.io.File; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
33 |
import java.io.FileInputStream; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
34 |
import java.io.IOException; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
35 |
import sun.tools.java.ClassDeclaration; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
36 |
import sun.tools.java.Identifier; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
37 |
import sun.rmi.rmic.BatchEnvironment; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
38 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
39 |
public class CFCTest { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
40 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
41 |
/* Constant table */ |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
42 |
private static final int CONSTANT_UTF8 = 1; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
43 |
private static final int CONSTANT_INTEGER = 3; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
44 |
private static final int CONSTANT_FLOAT = 4; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
45 |
private static final int CONSTANT_LONG = 5; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
46 |
private static final int CONSTANT_DOUBLE = 6; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
47 |
private static final int CONSTANT_CLASS = 7; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
48 |
private static final int CONSTANT_STRING = 8; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
49 |
private static final int CONSTANT_FIELD = 9; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
50 |
private static final int CONSTANT_METHOD = 10; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
51 |
private static final int CONSTANT_INTERFACEMETHOD = 11; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
52 |
private static final int CONSTANT_NAMEANDTYPE = 12; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
53 |
private static final int CONSTANT_METHODHANDLE = 15; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
54 |
private static final int CONSTANT_METHODTYPE = 16; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
55 |
private static final int CONSTANT_INVOKEDYNAMIC = 18; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
56 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
57 |
String testClassName = this.getClass().getCanonicalName(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
58 |
String testClassPath = System.getProperty("test.classes", "."); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
59 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
60 |
interface I { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
61 |
int get(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
62 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
63 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
64 |
public static void main(String[] args) throws Exception { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
65 |
new CFCTest().testNewConstants(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
66 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
67 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
68 |
void testNewConstants() throws Exception { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
69 |
// Presence of lambda causes new constant pool constant types to be used |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
70 |
I lam = () -> 88; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
71 |
if (lam.get() == 88) { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
72 |
System.out.println("Sanity passed: Lambda worked."); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
73 |
} else { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
74 |
throw new RuntimeException("Sanity failed: bad lambda execution"); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
75 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
76 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
77 |
// Verify that all the new constant pool constant types are present |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
78 |
String clsName = testClassPath + File.separator + testClassName + ".class"; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
79 |
ClassConstantChecker ccc = new ClassConstantChecker(clsName); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
80 |
ccc.checkFound(CONSTANT_METHODHANDLE); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
81 |
ccc.checkFound(CONSTANT_METHODTYPE); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
82 |
ccc.checkFound(CONSTANT_INVOKEDYNAMIC); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
83 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
84 |
// Heart of test: read the class file with the new constant types |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
85 |
exerciseClassDefinition(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
86 |
System.out.println("ClassDefinition read without failure.\n"); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
87 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
88 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
89 |
/** |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
90 |
* Failure is seen when getClassDefinition causes class read |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
91 |
*/ |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
92 |
void exerciseClassDefinition() throws Exception { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
93 |
BatchEnvironment env = new BatchEnvironment(System.out, |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
94 |
BatchEnvironment.createClassPath(testClassPath, null, null), |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
95 |
null); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
96 |
try { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
97 |
ClassDeclaration decl = env.getClassDeclaration( |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
98 |
Identifier.lookup(testClassName)); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
99 |
decl.getClassDefinition(env); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
100 |
} finally { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
101 |
env.flushErrors(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
102 |
env.shutdown(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
103 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
104 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
105 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
106 |
private class ClassConstantChecker { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
107 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
108 |
private DataInputStream in; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
109 |
private boolean[] found; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
110 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
111 |
ClassConstantChecker(String clsName) throws IOException { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
112 |
in = new DataInputStream(new FileInputStream(clsName)); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
113 |
found = new boolean[CONSTANT_INVOKEDYNAMIC + 20]; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
114 |
try { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
115 |
check(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
116 |
} finally { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
117 |
in.close(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
118 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
119 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
120 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
121 |
void checkFound(int tag) throws Exception { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
122 |
if (found[tag]) { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
123 |
System.out.printf("Constant pool tag found: %d\n", tag); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
124 |
} else { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
125 |
throw new RuntimeException("Insufficient test, constant pool tag NOT found: " + tag); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
126 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
127 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
128 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
129 |
private void skip(int n) throws IOException { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
130 |
if (in.skipBytes(n) != n) { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
131 |
throw new EOFException(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
132 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
133 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
134 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
135 |
private void check() throws IOException { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
136 |
skip(8); // magic, version |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
137 |
int count = in.readUnsignedShort(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
138 |
for (int i = 1; i < count; i++) { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
139 |
int j = i; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
140 |
// JVM 4.4 cp_info.tag |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
141 |
int tag = in.readByte(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
142 |
found[tag] = true; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
143 |
switch (tag) { |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
144 |
case CONSTANT_UTF8: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
145 |
in.readUTF(); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
146 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
147 |
case CONSTANT_LONG: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
148 |
case CONSTANT_DOUBLE: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
149 |
skip(8); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
150 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
151 |
case CONSTANT_CLASS: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
152 |
case CONSTANT_STRING: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
153 |
skip(2); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
154 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
155 |
case CONSTANT_INTEGER: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
156 |
case CONSTANT_FLOAT: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
157 |
case CONSTANT_FIELD: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
158 |
case CONSTANT_METHOD: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
159 |
case CONSTANT_INTERFACEMETHOD: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
160 |
case CONSTANT_NAMEANDTYPE: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
161 |
skip(4); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
162 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
163 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
164 |
case CONSTANT_METHODHANDLE: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
165 |
skip(3); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
166 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
167 |
case CONSTANT_METHODTYPE: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
168 |
skip(2); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
169 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
170 |
case CONSTANT_INVOKEDYNAMIC: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
171 |
skip(4); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
172 |
break; |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
173 |
|
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
174 |
case 0: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
175 |
default: |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
176 |
throw new ClassFormatError("invalid constant type: " + tag); |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
177 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
178 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
179 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
180 |
} |
9371f5046d02
8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries
rfield
parents:
diff
changeset
|
181 |
} |