6767import com .google .turbine .model .TurbineFlag ;
6868import com .google .turbine .model .TurbineTyKind ;
6969import com .google .turbine .model .TurbineVisibility ;
70+ import com .google .turbine .options .LanguageVersion ;
7071import com .google .turbine .type .AnnoInfo ;
7172import com .google .turbine .type .Type ;
7273import com .google .turbine .type .Type .ArrayTy ;
@@ -112,24 +113,28 @@ public ImmutableSet<ClassSymbol> symbols() {
112113
113114 /** Lowers all given classes to bytecode. */
114115 public static Lowered lowerAll (
116+ LanguageVersion languageVersion ,
115117 ImmutableMap <ClassSymbol , SourceTypeBoundClass > units ,
116118 ImmutableList <SourceModuleInfo > modules ,
117119 Env <ClassSymbol , BytecodeBoundClass > classpath ) {
118120 CompoundEnv <ClassSymbol , TypeBoundClass > env =
119121 CompoundEnv .<ClassSymbol , TypeBoundClass >of (classpath ).append (new SimpleEnv <>(units ));
120122 ImmutableMap .Builder <String , byte []> result = ImmutableMap .builder ();
121123 Set <ClassSymbol > symbols = new LinkedHashSet <>();
124+ int majorVersion = languageVersion .majorVersion ();
122125 for (ClassSymbol sym : units .keySet ()) {
123- result .put (sym .binaryName (), lower (units .get (sym ), env , sym , symbols ));
126+ result .put (sym .binaryName (), lower (units .get (sym ), env , sym , symbols , majorVersion ));
124127 }
125128 if (modules .size () == 1 ) {
126129 // single module mode: the module-info.class file is at the root
127- result .put ("module-info" , lower (getOnlyElement (modules ), env , symbols ));
130+ result .put ("module-info" , lower (getOnlyElement (modules ), env , symbols , majorVersion ));
128131 } else {
129132 // multi-module mode: the output module-info.class are in a directory corresponding to their
130133 // package
131134 for (SourceModuleInfo module : modules ) {
132- result .put (module .name ().replace ('.' , '/' ) + "/module-info" , lower (module , env , symbols ));
135+ result .put (
136+ module .name ().replace ('.' , '/' ) + "/module-info" ,
137+ lower (module , env , symbols , majorVersion ));
133138 }
134139 }
135140 return new Lowered (result .build (), ImmutableSet .copyOf (symbols ));
@@ -140,15 +145,17 @@ public static byte[] lower(
140145 SourceTypeBoundClass info ,
141146 Env <ClassSymbol , TypeBoundClass > env ,
142147 ClassSymbol sym ,
143- Set <ClassSymbol > symbols ) {
144- return new Lower (env ).lower (info , sym , symbols );
148+ Set <ClassSymbol > symbols ,
149+ int majorVersion ) {
150+ return new Lower (env ).lower (info , sym , symbols , majorVersion );
145151 }
146152
147153 private static byte [] lower (
148154 SourceModuleInfo module ,
149155 CompoundEnv <ClassSymbol , TypeBoundClass > env ,
150- Set <ClassSymbol > symbols ) {
151- return new Lower (env ).lower (module , symbols );
156+ Set <ClassSymbol > symbols ,
157+ int majorVersion ) {
158+ return new Lower (env ).lower (module , symbols , majorVersion );
152159 }
153160
154161 private final LowerSignature sig = new LowerSignature ();
@@ -158,7 +165,7 @@ public Lower(Env<ClassSymbol, TypeBoundClass> env) {
158165 this .env = env ;
159166 }
160167
161- private byte [] lower (SourceModuleInfo module , Set <ClassSymbol > symbols ) {
168+ private byte [] lower (SourceModuleInfo module , Set <ClassSymbol > symbols , int majorVersion ) {
162169 String name = "module-info" ;
163170 ImmutableList <AnnotationInfo > annotations = lowerAnnotations (module .annos ());
164171 ClassFile .ModuleInfo moduleInfo = lowerModule (module );
@@ -177,6 +184,7 @@ private byte[] lower(SourceModuleInfo module, Set<ClassSymbol> symbols) {
177184 ClassFile classfile =
178185 new ClassFile (
179186 /* access= */ TurbineFlag .ACC_MODULE ,
187+ majorVersion ,
180188 name ,
181189 /* signature= */ null ,
182190 /* superClass= */ null ,
@@ -238,7 +246,8 @@ private ClassFile.ModuleInfo lowerModule(SourceModuleInfo module) {
238246 provides .build ());
239247 }
240248
241- private byte [] lower (SourceTypeBoundClass info , ClassSymbol sym , Set <ClassSymbol > symbols ) {
249+ private byte [] lower (
250+ SourceTypeBoundClass info , ClassSymbol sym , Set <ClassSymbol > symbols , int majorVersion ) {
242251 int access = classAccess (info );
243252 String name = sig .descriptor (sym );
244253 String signature = sig .classSignature (info , env );
@@ -275,6 +284,7 @@ private byte[] lower(SourceTypeBoundClass info, ClassSymbol sym, Set<ClassSymbol
275284 ClassFile classfile =
276285 new ClassFile (
277286 access ,
287+ majorVersion ,
278288 name ,
279289 signature ,
280290 superName ,
0 commit comments