aboutsummaryrefslogtreecommitdiff
path: root/java/com/google/turbine/bytecode/ClassWriter.java
diff options
context:
space:
mode:
authorLiam Miller-Cushon <cushon@google.com>2021-09-23 14:49:01 -0700
committerJavac Team <javac-team+copybara@google.com>2021-09-23 14:49:37 -0700
commit006a74b6cd7565221a2d7fe9593c103bdd83584c (patch)
tree93951e8f0555322ac540a87c4fe378e6eb655784 /java/com/google/turbine/bytecode/ClassWriter.java
parent6b0f9e9b742af624b39eb890988ce9e40a80f212 (diff)
downloadturbine-006a74b6cd7565221a2d7fe9593c103bdd83584c.tar.gz
Improve major version handling
Parse -source/-target/--release flags from provided javacopts, and use them to set the major version of the classfile outputs, instead of trying to use the lowest possible version that supported the features in the output. PiperOrigin-RevId: 398583014
Diffstat (limited to 'java/com/google/turbine/bytecode/ClassWriter.java')
-rw-r--r--java/com/google/turbine/bytecode/ClassWriter.java16
1 files changed, 1 insertions, 15 deletions
diff --git a/java/com/google/turbine/bytecode/ClassWriter.java b/java/com/google/turbine/bytecode/ClassWriter.java
index 8b17e04..da4afc7 100644
--- a/java/com/google/turbine/bytecode/ClassWriter.java
+++ b/java/com/google/turbine/bytecode/ClassWriter.java
@@ -115,25 +115,11 @@ public final class ClassWriter {
ByteArrayDataOutput result = ByteStreams.newDataOutput();
result.writeInt(MAGIC);
result.writeShort(MINOR_VERSION);
- result.writeShort(majorVersion(classfile));
+ result.writeShort(classfile.majorVersion());
writeConstantPool(pool, result);
result.write(body.toByteArray());
return result.toByteArray();
}
- // use the lowest classfile version possible given the class file features
- // TODO(cushon): is there a reason to support --release?
- private static int majorVersion(ClassFile classfile) {
- if (classfile.nestHost() != null
- || !classfile.nestMembers().isEmpty()
- || classfile.record() != null) {
- return 60;
- }
- if (classfile.module() != null) {
- return 53;
- }
- return 52;
- }
-
private ClassWriter() {}
}