aboutsummaryrefslogtreecommitdiff
path: root/java/com/google
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2018-08-02 10:19:44 -0700
committerLiam Miller-Cushon <cushon@google.com>2018-08-03 11:31:11 -0700
commit97f8372640fe2b1970b435883910a61a595de4da (patch)
tree946d7e1e32d839b1c6c63e84c68178b7f625200f /java/com/google
parent695f2b6a457dc96347380ac8e4aebf804a376cea (diff)
downloadturbine-97f8372640fe2b1970b435883910a61a595de4da.tar.gz
Prepare turbine for JDK 10
Including handling module-info's in ct.sym for JDK 10 and up. Don't assert on unsupported class file major versions; we'll still find out if changes are necessary. MOE_MIGRATED_REVID=207294946
Diffstat (limited to 'java/com/google')
-rw-r--r--java/com/google/turbine/binder/CtSymClassBinder.java10
-rw-r--r--java/com/google/turbine/bytecode/ClassReader.java2
2 files changed, 9 insertions, 3 deletions
diff --git a/java/com/google/turbine/binder/CtSymClassBinder.java b/java/com/google/turbine/binder/CtSymClassBinder.java
index 5988ac5..8e15c1b 100644
--- a/java/com/google/turbine/binder/CtSymClassBinder.java
+++ b/java/com/google/turbine/binder/CtSymClassBinder.java
@@ -20,6 +20,7 @@ import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.turbine.binder.bound.ModuleInfo;
+import com.google.turbine.binder.bytecode.BytecodeBinder;
import com.google.turbine.binder.bytecode.BytecodeBoundClass;
import com.google.turbine.binder.env.Env;
import com.google.turbine.binder.env.SimpleEnv;
@@ -47,6 +48,7 @@ public class CtSymClassBinder {
throw new IllegalStateException("lib/ct.sym does not exist in " + javaHome);
}
Map<ClassSymbol, BytecodeBoundClass> map = new HashMap<>();
+ Map<ModuleSymbol, ModuleInfo> modules = new HashMap<>();
Env<ClassSymbol, BytecodeBoundClass> benv =
new Env<ClassSymbol, BytecodeBoundClass>() {
@Override
@@ -70,6 +72,11 @@ public class CtSymClassBinder {
if (!ze.name().substring(0, idx).contains(version)) {
continue;
}
+ if (name.substring(name.lastIndexOf('/') + 1).equals("module-info.sig")) {
+ ModuleInfo moduleInfo = BytecodeBinder.bindModuleInfo(name, toByteArrayOrDie(ze));
+ modules.put(new ModuleSymbol(moduleInfo.name()), moduleInfo);
+ continue;
+ }
ClassSymbol sym = new ClassSymbol(name.substring(idx + 1, name.length() - ".sig".length()));
if (!map.containsKey(sym)) {
map.put(
@@ -81,8 +88,7 @@ public class CtSymClassBinder {
return null;
}
SimpleEnv<ClassSymbol, BytecodeBoundClass> env = new SimpleEnv<>(ImmutableMap.copyOf(map));
- // TODO(cushon): support ct.sym module-infos once they exist (JDK 10?)
- Env<ModuleSymbol, ModuleInfo> moduleEnv = new SimpleEnv<>(ImmutableMap.of());
+ Env<ModuleSymbol, ModuleInfo> moduleEnv = new SimpleEnv<>(ImmutableMap.copyOf(modules));
TopLevelIndex index = SimpleTopLevelIndex.of(env.asMap().keySet());
return new ClassPath() {
@Override
diff --git a/java/com/google/turbine/bytecode/ClassReader.java b/java/com/google/turbine/bytecode/ClassReader.java
index 0032e63..1a98ce3 100644
--- a/java/com/google/turbine/bytecode/ClassReader.java
+++ b/java/com/google/turbine/bytecode/ClassReader.java
@@ -74,7 +74,7 @@ public class ClassReader {
}
int minorVersion = reader.u2();
int majorVersion = reader.u2();
- if (majorVersion < 45 || majorVersion > 53) {
+ if (majorVersion < 45) {
throw error("bad version: %d.%d", majorVersion, minorVersion);
}
ConstantPoolReader constantPool = ConstantPoolReader.readConstantPool(reader);