From 97f8372640fe2b1970b435883910a61a595de4da Mon Sep 17 00:00:00 2001 From: cushon Date: Thu, 2 Aug 2018 10:19:44 -0700 Subject: 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 --- java/com/google/turbine/binder/CtSymClassBinder.java | 10 ++++++++-- java/com/google/turbine/bytecode/ClassReader.java | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'java/com/google') 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 map = new HashMap<>(); + Map modules = new HashMap<>(); Env benv = new Env() { @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 env = new SimpleEnv<>(ImmutableMap.copyOf(map)); - // TODO(cushon): support ct.sym module-infos once they exist (JDK 10?) - Env moduleEnv = new SimpleEnv<>(ImmutableMap.of()); + Env 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); -- cgit v1.2.3