--- old/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java 2016-12-15 09:20:02.439515297 +0000 +++ new/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java 2016-12-15 09:20:02.332507976 +0000 @@ -58,6 +58,8 @@ import com.sun.tools.classfile.Type.WildcardType; import static com.sun.tools.classfile.AccessFlags.*; +import static com.sun.tools.classfile.ConstantPool.CONSTANT_Module; +import static com.sun.tools.classfile.ConstantPool.CONSTANT_Package; /* * The main javap class to write the contents of a class file as text. @@ -166,7 +168,12 @@ Module_attribute modAttr = (Module_attribute) attr; String name; try { - name = getJavaName(constant_pool.getUTF8Value(modAttr.module_name)); + // FIXME: compatibility code + if (constant_pool.get(modAttr.module_name).getTag() == CONSTANT_Module) { + name = getJavaName(constant_pool.getModuleInfo(modAttr.module_name).getName()); + } else { + name = getJavaName(constant_pool.getUTF8Value(modAttr.module_name)); + } } catch (ConstantPoolException e) { name = report(e); } @@ -175,6 +182,10 @@ } print("module "); print(name); + if (modAttr.module_version_index != 0) { + print("@"); + print(getUTF8Value(modAttr.module_version_index)); + } } else { // fallback for malformed class files print("class "); @@ -602,19 +613,31 @@ if ((entry.requires_flags & Module_attribute.ACC_TRANSITIVE) != 0) print(" transitive"); print(" "); - print(getUTF8Value(entry.requires_index).replace('/', '.')); + String mname; + try { + mname = getModuleName(entry.requires_index); + } catch (ConstantPoolException e) { + mname = report(e); + } + print(mname); println(";"); } for (Module_attribute.ExportsEntry entry: m.exports) { print("exports"); print(" "); - print(getUTF8Value(entry.exports_index).replace('/', '.')); + String pname; + try { + pname = getPackageName(entry.exports_index).replace('/', '.'); + } catch (ConstantPoolException e) { + pname = report(e); + } + print(pname); boolean first = true; for (int i: entry.exports_to_index) { String mname; try { - mname = classFile.constant_pool.getUTF8Value(i).replace('/', '.'); + mname = getModuleName(i); } catch (ConstantPoolException e) { mname = report(e); } @@ -635,12 +658,18 @@ for (Module_attribute.OpensEntry entry: m.opens) { print("opens"); print(" "); - print(getUTF8Value(entry.opens_index).replace('/', '.')); + String pname; + try { + pname = getPackageName(entry.opens_index).replace('/', '.'); + } catch (ConstantPoolException e) { + pname = report(e); + } + print(pname); boolean first = true; for (int i: entry.opens_to_index) { String mname; try { - mname = classFile.constant_pool.getUTF8Value(i).replace('/', '.'); + mname = getModuleName(i); } catch (ConstantPoolException e) { mname = report(e); } @@ -684,6 +713,22 @@ } } + String getModuleName(int index) throws ConstantPoolException { + if (constant_pool.get(index).getTag() == CONSTANT_Module) { + return constant_pool.getModuleInfo(index).getName(); + } else { + return constant_pool.getUTF8Value(index); + } + } + + String getPackageName(int index) throws ConstantPoolException { + if (constant_pool.get(index).getTag() == CONSTANT_Package) { + return constant_pool.getPackageInfo(index).getName(); + } else { + return constant_pool.getUTF8Value(index); + } + } + String getUTF8Value(int index) { try { return classFile.constant_pool.getUTF8Value(index);