mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8313422: test/langtools/tools/javac 144 test classes uses com.sun.tools.classfile library
Reviewed-by: asotona
This commit is contained in:
parent
8557205a82
commit
8f7e29b2cd
144 changed files with 2743 additions and 2762 deletions
|
@ -25,30 +25,33 @@
|
|||
* @test
|
||||
* @bug 8015927
|
||||
* @summary Class reference duplicates in constant pool
|
||||
* @modules jdk.jdeps/com.sun.tools.classfile
|
||||
* @modules java.base/jdk.internal.classfile
|
||||
* java.base/jdk.internal.classfile.attribute
|
||||
* java.base/jdk.internal.classfile.constantpool
|
||||
* java.base/jdk.internal.classfile.instruction
|
||||
* java.base/jdk.internal.classfile.components
|
||||
* @clean ClassRefDupInConstantPoolTest$Duplicates
|
||||
* @run main ClassRefDupInConstantPoolTest
|
||||
*/
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.sun.tools.classfile.*;
|
||||
import com.sun.tools.classfile.ConstantPool.*;
|
||||
import jdk.internal.classfile.*;
|
||||
import jdk.internal.classfile.constantpool.*;
|
||||
|
||||
public class ClassRefDupInConstantPoolTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
ClassFile cls = ClassFile.read(ClassRefDupInConstantPoolTest.class.
|
||||
getResourceAsStream("ClassRefDupInConstantPoolTest$Duplicates.class"));
|
||||
ConstantPool pool = cls.constant_pool;
|
||||
ClassModel cls = Classfile.of().parse(ClassRefDupInConstantPoolTest.class.
|
||||
getResourceAsStream("ClassRefDupInConstantPoolTest$Duplicates.class").readAllBytes());
|
||||
ConstantPool pool = cls.constantPool();
|
||||
|
||||
int duplicates = 0;
|
||||
TreeSet<Integer> set = new TreeSet<>();
|
||||
for (CPInfo i : pool.entries()) {
|
||||
if (i.getTag() == ConstantPool.CONSTANT_Class) {
|
||||
CONSTANT_Class_info ci = (CONSTANT_Class_info)i;
|
||||
if (!set.add(ci.name_index)) {
|
||||
TreeSet<String> set = new TreeSet<>();
|
||||
for (int i = 1; i < pool.entryCount(); i += pool.entryByIndex(i).width()) {
|
||||
if (pool.entryByIndex(i) instanceof ClassEntry ce) {
|
||||
if (!set.add(ce.asInternalName())) {
|
||||
duplicates++;
|
||||
System.out.println("DUPLICATE CLASS REF " + ci.getName());
|
||||
System.out.println("DUPLICATE CLASS REF " + ce.asInternalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue