|
|
@ -286,46 +286,65 @@ public class ClassWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void writeModuleInfoBody(TextBuffer buffer, StructModuleAttribute moduleAttribute) { |
|
|
|
private static void writeModuleInfoBody(TextBuffer buffer, StructModuleAttribute moduleAttribute) { |
|
|
|
for (StructModuleAttribute.RequiresEntry requires : moduleAttribute.requires) { |
|
|
|
boolean newLineNeeded = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<StructModuleAttribute.RequiresEntry> requiresEntries = moduleAttribute.requires; |
|
|
|
|
|
|
|
if (!requiresEntries.isEmpty()) { |
|
|
|
|
|
|
|
for (StructModuleAttribute.RequiresEntry requires : requiresEntries) { |
|
|
|
buffer.appendIndent(1).append("requires ").append(requires.moduleName.replace('/', '.')).append(';').appendLineSeparator(); |
|
|
|
buffer.appendIndent(1).append("requires ").append(requires.moduleName.replace('/', '.')).append(';').appendLineSeparator(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newLineNeeded = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (StructModuleAttribute.ExportsEntry exports : moduleAttribute.exports) { |
|
|
|
List<StructModuleAttribute.ExportsEntry> exportsEntries = moduleAttribute.exports; |
|
|
|
|
|
|
|
if (!exportsEntries.isEmpty()) { |
|
|
|
|
|
|
|
if (newLineNeeded) buffer.appendLineSeparator(); |
|
|
|
|
|
|
|
for (StructModuleAttribute.ExportsEntry exports : exportsEntries) { |
|
|
|
buffer.appendIndent(1).append("exports ").append(exports.packageName.replace('/', '.')); |
|
|
|
buffer.appendIndent(1).append("exports ").append(exports.packageName.replace('/', '.')); |
|
|
|
|
|
|
|
|
|
|
|
List<String> exportToModules = exports.exportToModules; |
|
|
|
List<String> exportToModules = exports.exportToModules; |
|
|
|
if (exportToModules.size() > 0) { |
|
|
|
if (exportToModules.size() > 0) { |
|
|
|
buffer.append(" to").appendLineSeparator(); |
|
|
|
buffer.append(" to").appendLineSeparator(); |
|
|
|
appendFQClassNames(buffer, exportToModules); |
|
|
|
appendFQClassNames(buffer, exportToModules); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(';').appendLineSeparator(); |
|
|
|
buffer.append(';').appendLineSeparator(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newLineNeeded = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (StructModuleAttribute.OpensEntry opens : moduleAttribute.opens) { |
|
|
|
List<StructModuleAttribute.OpensEntry> opensEntries = moduleAttribute.opens; |
|
|
|
|
|
|
|
if (!opensEntries.isEmpty()) { |
|
|
|
|
|
|
|
if (newLineNeeded) buffer.appendLineSeparator(); |
|
|
|
|
|
|
|
for (StructModuleAttribute.OpensEntry opens : opensEntries) { |
|
|
|
buffer.appendIndent(1).append("opens ").append(opens.packageName.replace('/', '.')); |
|
|
|
buffer.appendIndent(1).append("opens ").append(opens.packageName.replace('/', '.')); |
|
|
|
|
|
|
|
|
|
|
|
List<String> opensToModules = opens.opensToModules; |
|
|
|
List<String> opensToModules = opens.opensToModules; |
|
|
|
if (opensToModules.size() > 0) { |
|
|
|
if (opensToModules.size() > 0) { |
|
|
|
buffer.append(" to").appendLineSeparator(); |
|
|
|
buffer.append(" to").appendLineSeparator(); |
|
|
|
appendFQClassNames(buffer, opensToModules); |
|
|
|
appendFQClassNames(buffer, opensToModules); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(';').appendLineSeparator(); |
|
|
|
buffer.append(';').appendLineSeparator(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newLineNeeded = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String uses : moduleAttribute.uses) { |
|
|
|
List<String> usesEntries = moduleAttribute.uses; |
|
|
|
|
|
|
|
if (!usesEntries.isEmpty()) { |
|
|
|
|
|
|
|
if (newLineNeeded) buffer.appendLineSeparator(); |
|
|
|
|
|
|
|
for (String uses : usesEntries) { |
|
|
|
buffer.appendIndent(1).append("uses ").append(ExprProcessor.buildJavaClassName(uses)).append(';').appendLineSeparator(); |
|
|
|
buffer.appendIndent(1).append("uses ").append(ExprProcessor.buildJavaClassName(uses)).append(';').appendLineSeparator(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newLineNeeded = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (StructModuleAttribute.ProvidesEntry provides : moduleAttribute.provides) { |
|
|
|
List<StructModuleAttribute.ProvidesEntry> providesEntries = moduleAttribute.provides; |
|
|
|
|
|
|
|
if (!providesEntries.isEmpty()) { |
|
|
|
|
|
|
|
if (newLineNeeded) buffer.appendLineSeparator(); |
|
|
|
|
|
|
|
for (StructModuleAttribute.ProvidesEntry provides : providesEntries) { |
|
|
|
buffer.appendIndent(1).append("provides ").append(ExprProcessor.buildJavaClassName(provides.interfaceName)).append(" with").appendLineSeparator(); |
|
|
|
buffer.appendIndent(1).append("provides ").append(ExprProcessor.buildJavaClassName(provides.interfaceName)).append(" with").appendLineSeparator(); |
|
|
|
@SuppressWarnings({"SSBasedInspection", "RedundantSuppression"}) List<String> javaNames = |
|
|
|
appendFQClassNames(buffer, provides.implementationNames.stream().map(ExprProcessor::buildJavaClassName).collect(Collectors.toList())); |
|
|
|
provides.implementationNames.stream().map(ExprProcessor::buildJavaClassName).collect(Collectors.toList()); |
|
|
|
|
|
|
|
appendFQClassNames(buffer, javaNames); |
|
|
|
|
|
|
|
buffer.append(';').appendLineSeparator(); |
|
|
|
buffer.append(';').appendLineSeparator(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void addTracer(StructClass cls, StructMethod method, BytecodeMappingTracer tracer) { |
|
|
|
private static void addTracer(StructClass cls, StructMethod method, BytecodeMappingTracer tracer) { |
|
|
|
StructLineNumberTableAttribute table = method.getAttribute(StructGeneralAttribute.ATTRIBUTE_LINE_NUMBER_TABLE); |
|
|
|
StructLineNumberTableAttribute table = method.getAttribute(StructGeneralAttribute.ATTRIBUTE_LINE_NUMBER_TABLE); |
|
|
|