diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index f5c2b8f956b90..8aa9b65bf6e33 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -248,7 +248,6 @@ public enum Feature { UNNAMED_CLASSES(JDK21, Fragments.FeatureUnnamedClasses, DiagKind.PLURAL), WARN_ON_ILLEGAL_UTF8(MIN, JDK21), UNNAMED_VARIABLES(JDK21, Fragments.FeatureUnnamedVariables, DiagKind.PLURAL), - LAZY_STATICS(JDK22), ; enum DiagKind { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index 30e5172c76537..9e08a8cdd83af 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -1783,20 +1783,10 @@ public Object getConstValue() { } catch (Exception ex) { throw new AssertionError(ex); } - } else if (data instanceof DynamicVarSymbol) { - return null; // ignore } return data; } - public DynamicVarSymbol lazyConstValue() { - if (data instanceof DynamicVarSymbol dsym) { - return dsym; - } else { - return null; - } - } - public void setData(Object data) { Assert.check(!(data instanceof Env), this); this.data = data; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index c4022cfccc831..676b7778f0e9d 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -247,7 +247,7 @@ public static Symtab instance(Context context) { public final Type processorType; public final Type linkageType; - // for lazy statics + // for static locals public final Type constantBootstraps; /** The symbol representing the length field of an array. @@ -648,7 +648,7 @@ public R accept(ElementVisitor v, P p) { processorType = enterClass("java.lang.StringTemplate$Processor"); linkageType = enterClass("java.lang.StringTemplate$Processor$Linkage"); - // for lazy statics + // for static locals constantBootstraps = enterClass("java.lang.invoke.ConstantBootstraps"); // Enter a synthetic class that is used to mark internal diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 39f3171d8b1f6..d92a8807542dd 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -1213,10 +1213,8 @@ long checkFlags(DiagnosticPosition pos, long flags, Symbol sym, JCTree tree) { mask = ReceiverParamFlags; else if (sym.owner.kind != TYP) mask = LocalVarFlags; - else if ((sym.owner.flags_field & INTERFACE) != 0) { - implicit = InterfaceVarFlags; - mask = InterfaceVarFlags; - } + else if ((sym.owner.flags_field & INTERFACE) != 0) + mask = implicit = InterfaceVarFlags; else mask = VarFlags; break; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java index 0f808af030853..671ed3dc9340f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CompileStates.java @@ -61,9 +61,10 @@ public enum CompileState { TRANSTYPES(6), TRANSLITERALS(7), TRANSPATTERNS(8), - UNLAMBDA(9), - LOWER(10), - GENERATE(11); + TRANSCONSTANTS(9), + UNLAMBDA(10), + LOWER(11), + GENERATE(12); CompileState(int value) { this.value = value; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index c5f66fc5ea396..eb99897ee5944 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -1124,10 +1124,6 @@ MethodSymbol accessSymbol(Symbol sym, JCTree tree, JCTree enclOp, return accessor; } - Name lazyStaticInitName(Symbol sym) { - return sym.name.append('$', names.fromString("init")); - } - /** The qualifier to be used for accessing a symbol in an outer class. * This is either C.sym or C.this.sym, depending on whether or not * sym is static. @@ -1259,6 +1255,7 @@ JCExpression access(Symbol sym, JCExpression tree, JCExpression enclOp, boolean break; case MTH: case VAR: if (sym.owner.kind == TYP) { + // Access methods are required for // - private members, // - protected members in a superclass of an @@ -3675,47 +3672,11 @@ public void visitVarDef(JCVariableDecl tree) { names.empty, null, currentClass); } - // handle static locals - if (tree.sym.isStatic() && tree.sym.owner.kind == MTH) { - splitInit(tree); - } else { - if (tree.init != null) tree.init = translate(tree.init, tree.type); - } + if (tree.init != null) tree.init = translate(tree.init, tree.type); result = tree; currentMethodSym = oldMethodSym; } - private MethodSymbol splitInit(JCVariableDecl tree) { - Assert.checkNonNull(tree.init); - // create synthetic init symbol - MethodSymbol initSym = new MethodSymbol( - STATIC | SYNTHETIC | PRIVATE, - tree.name.append('$', names.fromString("init")), - new MethodType(List.nil(), tree.type, List.nil(), syms.methodClass), - currentClass); - enterSynthetic(tree.pos(), initSym, currentClass.members()); - // create synthetic init tree - JCExpression initExpr = translate(tree.init, tree.type); - JCMethodDecl initDef = make.MethodDef(initSym, make.Block(0, List.of(make.Return(initExpr)))); - JCClassDecl currentDecl = classDef(currentClass); - currentDecl.defs = currentDecl.defs.prepend(initDef); - // drop original init - tree.init = null; - List lazyInit_staticArgTypes = List.of(syms.methodHandleLookupType, - syms.stringType, - syms.classType, - syms.methodHandleType); - - MethodSymbol bsm = rs.resolveInternalMethod(tree, attrEnv, syms.constantBootstraps, - names.invoke, lazyInit_staticArgTypes, List.nil()); - - // set a constant value that points to a dynamic symbol, so that Gen can emit the correct ldc - tree.sym.setData(new DynamicVarSymbol(tree.name, currentClass, bsm.asHandle(), tree.type, - new LoadableConstant[] { initSym.asHandle() })); - - return initSym; - } - public void visitBlock(JCBlock tree) { MethodSymbol oldMethodSym = currentMethodSym; if (currentMethodSym == null) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransConstants.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransConstants.java new file mode 100644 index 0000000000000..ede46cacb7fa2 --- /dev/null +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransConstants.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.javac.comp; + +import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.Scope.WriteableScope; +import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Symbol.DynamicVarSymbol; +import com.sun.tools.javac.code.Symbol.MethodSymbol; +import com.sun.tools.javac.code.Symbol.VarSymbol; +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Type.MethodType; +import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant; +import com.sun.tools.javac.jvm.Target; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; +import com.sun.tools.javac.tree.JCTree.JCExpression; +import com.sun.tools.javac.tree.JCTree.JCIdent; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCNewClass; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.tree.TreeMaker; +import com.sun.tools.javac.tree.TreeScanner; +import com.sun.tools.javac.tree.TreeTranslator; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Names; + +import java.util.HashMap; +import java.util.Map; + +import static com.sun.tools.javac.code.Flags.PRIVATE; +import static com.sun.tools.javac.code.Flags.STATIC; +import static com.sun.tools.javac.code.Flags.SYNTHETIC; +import static com.sun.tools.javac.code.Kinds.Kind.MTH; + +public class TransConstants extends TreeTranslator { + + protected static final Context.Key transConstantsKey = new Context.Key<>(); + + public static TransConstants instance(Context context) { + TransConstants instance = context.get(transConstantsKey); + if (instance == null) + instance = new TransConstants(context); + return instance; + } + + private final Names names; + private final Symtab syms; + private TreeMaker make; + private Resolve rs; + private Target target; + + @SuppressWarnings("this-escape") + protected TransConstants(Context context) { + context.put(transConstantsKey, this); + names = Names.instance(context); + syms = Symtab.instance(context); + make = TreeMaker.instance(context); + rs = Resolve.instance(context); + target = Target.instance(context); + } + + /** The currently enclosing class. + */ + JCClassDecl currentClass; + + /** Environment for symbol lookup, set by translateTopLevelClass. + */ + Env attrEnv; + + /** A table mapping static local symbols to their desugared counterparts. + */ + Map staticLocalsTable; + + ListBuffer pendingClassDefs; + + public void visitVarDef(JCVariableDecl tree) { + if (tree.sym.isStatic() && tree.sym.owner.kind == MTH) { + if (isSplittableStaticLocal(tree)) { + splitStaticLocalInit(tree); + } else { + liftStaticLocal(tree); + } + // do not emit the variable declaration + result = make.Skip(); + } else { + super.visitVarDef(tree); + } + } + + @Override + public void visitIdent(JCIdent tree) { + if (staticLocalsTable != null && staticLocalsTable.containsKey(tree.sym)) { + Symbol translatedSym = staticLocalsTable.get(tree.sym); + result = make.Ident(translatedSym); + } else { + super.visitIdent(tree); + } + } + + @Override + public void visitMethodDef(JCMethodDecl tree) { + Map prevStaticLocalsTable = staticLocalsTable; + try { + staticLocalsTable = new HashMap<>(); + super.visitMethodDef(tree); + } finally { + staticLocalsTable = prevStaticLocalsTable; + } + } + + @Override + public void visitClassDef(JCClassDecl tree) { + JCClassDecl prevClass = currentClass; + ListBuffer prevPendingClassDefs = pendingClassDefs; + try { + currentClass = tree; + pendingClassDefs = new ListBuffer<>(); + super.visitClassDef(tree); + tree.defs = tree.defs.appendList(pendingClassDefs.toList()); + } finally { + currentClass = prevClass; + pendingClassDefs = prevPendingClassDefs; + } + } + + boolean isSplittableStaticLocal(JCVariableDecl tree) { + return tree.sym.isFinal() && + !hasAnonClassDefs(tree); + } + + boolean hasAnonClassDefs(JCTree tree) { + class AnonClassFinder extends TreeScanner { + boolean anonFound; + + @Override + public void visitNewClass(JCNewClass tree) { + if (tree.def != null) { + anonFound = true; + } + super.visitNewClass(tree); + } + + @Override + public void visitClassDef(JCClassDecl tree) { + // do not recurse + } + } + AnonClassFinder anonClassFinder = new AnonClassFinder(); + tree.accept(anonClassFinder); + return anonClassFinder.anonFound; + } + + private void splitStaticLocalInit(JCVariableDecl tree) { + Assert.checkNonNull(tree.init); + // create synthetic init symbol + MethodSymbol initSym = new MethodSymbol( + STATIC | SYNTHETIC | PRIVATE, + tree.name.append('$', names.fromString("init")), + new MethodType(List.nil(), tree.type, List.nil(), syms.methodClass), + currentClass.sym); + enterSynthetic(tree.pos(), initSym, currentClass.sym.members()); + // create synthetic init tree + JCExpression initExpr = translate(tree.init); + JCMethodDecl initDef = make.MethodDef(initSym, make.Block(0, List.of(make.Return(initExpr)))); + pendingClassDefs.add(initDef); + // drop original init + tree.init = null; + List lazyInit_staticArgTypes = List.of(syms.methodHandleLookupType, + syms.stringType, + syms.classType, + syms.methodHandleType); + + MethodSymbol bsm = rs.resolveInternalMethod(tree, attrEnv, syms.constantBootstraps, + names.invoke, lazyInit_staticArgTypes, List.nil()); + + // set a constant value that points to a dynamic symbol, so that Gen can emit the correct ldc + DynamicVarSymbol condySym = new DynamicVarSymbol(tree.name, currentClass.sym, bsm.asHandle(), tree.type, + new LoadableConstant[] { initSym.asHandle() }); + staticLocalsTable.put(tree.sym, condySym); + } + + private void liftStaticLocal(JCVariableDecl tree) { + Assert.checkNonNull(tree.init); + // create synthetic init symbol + VarSymbol liftedSym = new VarSymbol( + STATIC | SYNTHETIC | PRIVATE, + makeSyntheticName(tree.name.append('$', names.fromString("static")), currentClass.sym.members()), + tree.sym.type, currentClass.sym); + enterSynthetic(tree.pos(), liftedSym, currentClass.sym.members()); + // create synthetic init tree + JCExpression initExpr = translate(tree.init); + JCVariableDecl liftedDecl = make.VarDef(liftedSym, initExpr); + pendingClassDefs.add(liftedDecl); + staticLocalsTable.put(tree.sym, liftedSym); + } + + // copied from Lower + private void enterSynthetic(DiagnosticPosition pos, Symbol sym, WriteableScope s) { + s.enter(sym); + } + + private Name makeSyntheticName(Name name, Scope s) { + do { + name = name.append( + target.syntheticNameChar(), + names.empty); + } while (lookupSynthetic(name, s) != null); + return name; + } + + private Symbol lookupSynthetic(Name name, Scope s) { + Symbol sym = s.findFirst(name); + return (sym==null || (sym.flags()&SYNTHETIC)==0) ? null : sym; + } + + /** Translate a toplevel class and return a list consisting of + * the translated class and translated versions of all inner classes. + * @param env The attribution environment current at the class definition. + * We need this for resolving some additional symbols. + * @param cdef The tree representing the class definition. + */ + public JCTree translateTopLevelClass(Env env, JCTree cdef, TreeMaker make) { + try { + attrEnv = env; + this.make = make; + currentClass = null; + return translate(cdef); + } finally { + // note that recursive invocations of this method fail hard + attrEnv = null; + this.make = null; + currentClass = null; + } + } +} diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 18d1a219ad010..aed63c44bb165 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -982,12 +982,6 @@ void writeField(VarSymbol v) { endAttr(alenIdx); acount++; } - if (v.lazyConstValue() != null) { - int alenIdx = writeAttr(names.LazyValue); - databuf.appendChar(poolWriter.putConstant(v.lazyConstValue())); - endAttr(alenIdx); - acount++; - } acount += writeMemberAttrs(v, false); acount += writeExtraAttributes(v); endAttrs(acountIdx, acount); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java index b129b3902a709..caa5249bb8324 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -2319,9 +2319,6 @@ public void visitIndexed(JCArrayAccess tree) { public void visitIdent(JCIdent tree) { Symbol sym = tree.sym; - if (isStaticLocal(sym)) { - sym = ((VarSymbol)sym).lazyConstValue(); - } if (tree.name == names._this || tree.name == names._super) { Item res = tree.name == names._this ? items.makeThisItem() @@ -2394,10 +2391,7 @@ public void visitSelect(JCFieldAccess tree) { result = items. makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue()); } else { - if (isInvokeDynamic(sym) || isConstantDynamic(sym)) { - if (isConstantDynamic(sym)) { - setTypeAnnotationPositions(tree.pos); - } + if (isInvokeDynamic(sym)) { result = items.makeDynamicItem(sym); return; } else { @@ -2427,12 +2421,6 @@ public boolean isInvokeDynamic(Symbol sym) { return sym.kind == MTH && ((MethodSymbol)sym).isDynamic(); } - public boolean isStaticLocal(Symbol sym) { - return sym.kind == VAR && - sym.isStatic() && - sym.owner.kind == MTH; - } - public void visitLiteral(JCLiteral tree) { if (tree.type.hasTag(BOT)) { code.emitop0(aconst_null); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 82a7465821d4e..dce8f39b61c37 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1632,6 +1632,13 @@ public void visitSwitchExpression(JCSwitchExpression tree) { compileStates.put(env, CompileState.TRANSPATTERNS); + if (shouldStop(CompileState.TRANSCONSTANTS)) + return; + + env.tree = TransConstants.instance(context).translateTopLevelClass(env, env.tree, localMake); + + compileStates.put(env, CompileState.TRANSPATTERNS); + if (scanner.hasLambdas) { if (shouldStop(CompileState.UNLAMBDA)) return; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index 5cf9203ae61cd..f1f7c439d6371 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -4842,10 +4842,6 @@ protected boolean isSealedClassStart(boolean local) { return false; } - protected boolean isLazyStaticIdentifier() { - return false; - } - private boolean allowedAfterSealedOrNonSealed(Token next, boolean local, boolean currentIsNonSealed) { return local ? switch (next.kind) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java index 94c9d1ef79fa1..229c710f7df60 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java @@ -143,7 +143,6 @@ public static Names instance(Context context) { public final Name Enum; public final Name Exceptions; public final Name InnerClasses; - public final Name LazyValue; public final Name LineNumberTable; public final Name LocalVariableTable; public final Name LocalVariableTypeTable; @@ -236,9 +235,6 @@ public static Names instance(Context context) { public final Name newLargeStringTemplate; public final Name processStringTemplate; - // lazy statics - public final Name lazy; - public final Name.Table table; @SuppressWarnings("this-escape") @@ -343,7 +339,6 @@ public Names(Context context) { Enum = fromString("Enum"); Exceptions = fromString("Exceptions"); InnerClasses = fromString("InnerClasses"); - LazyValue = fromString("LazyValue"); LineNumberTable = fromString("LineNumberTable"); LocalVariableTable = fromString("LocalVariableTable"); LocalVariableTypeTable = fromString("LocalVariableTypeTable"); @@ -430,9 +425,6 @@ record = fromString("record"); typeSwitch = fromString("typeSwitch"); enumSwitch = fromString("enumSwitch"); enumConstant = fromString("enumConstant"); - - // lazy statics - lazy = fromString("lazy"); } protected Name.Table createTable(Options options) { diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java index 288d5d81539da..3ab3fce1863b8 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Attribute.java @@ -48,7 +48,6 @@ public abstract class Attribute { public static final String EnclosingMethod = "EnclosingMethod"; public static final String Exceptions = "Exceptions"; public static final String InnerClasses = "InnerClasses"; - public static final String LazyValue = "LazyValue"; public static final String LineNumberTable = "LineNumberTable"; public static final String LocalVariableTable = "LocalVariableTable"; public static final String LocalVariableTypeTable = "LocalVariableTypeTable"; @@ -125,7 +124,6 @@ protected void init() { standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class); standardAttributes.put(Exceptions, Exceptions_attribute.class); standardAttributes.put(InnerClasses, InnerClasses_attribute.class); - standardAttributes.put(LazyValue, LazyValue_attribute.class); standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class); standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class); standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class); @@ -193,7 +191,6 @@ public interface Visitor { R visitEnclosingMethod(EnclosingMethod_attribute attr, P p); R visitExceptions(Exceptions_attribute attr, P p); R visitInnerClasses(InnerClasses_attribute attr, P p); - R visitLazyValue(LazyValue_attribute attr, P p); R visitLineNumberTable(LineNumberTable_attribute attr, P p); R visitLocalVariableTable(LocalVariableTable_attribute attr, P p); R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java index 5a225856989ae..a24fb837f4309 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/ClassWriter.java @@ -481,12 +481,6 @@ protected void writeInnerClassesInfo(InnerClasses_attribute.Info info, ClassOutp writeAccessFlags(info.inner_class_access_flags, out); } - @Override - public Void visitLazyValue(LazyValue_attribute attr, ClassOutputStream out) { - out.writeShort(attr.lazyvalue_index); - return null; - } - @Override public Void visitLineNumberTable(LineNumberTable_attribute attr, ClassOutputStream out) { out.writeShort(attr.line_number_table.length); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/LazyValue_attribute.java b/src/jdk.jdeps/share/classes/com/sun/tools/classfile/LazyValue_attribute.java deleted file mode 100644 index ead7201b4e320..0000000000000 --- a/src/jdk.jdeps/share/classes/com/sun/tools/classfile/LazyValue_attribute.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.classfile; - -import java.io.IOException; - -/** - * See JVMS, section 4.8.x. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public class LazyValue_attribute extends Attribute { - LazyValue_attribute(ClassReader cr, int name_index, int length) throws IOException { - super(name_index, length); - lazyvalue_index = cr.readUnsignedShort(); - } - - public LazyValue_attribute(ConstantPool constant_pool, int lazyvalue_index) - throws ConstantPoolException { - this(constant_pool.getUTF8Index(Attribute.ConstantValue), lazyvalue_index); - } - - public LazyValue_attribute(int name_index, int lazyvalue_index) { - super(name_index, 2); - this.lazyvalue_index = lazyvalue_index; - } - - public R accept(Visitor visitor, D data) { - return visitor.visitLazyValue(this, data); - } - - public final int lazyvalue_index; -} diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java index 8a8c453f4f715..13c5c10e8909b 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java @@ -466,15 +466,6 @@ public void write(Attribute a, CodeAttribute lr) { println("// " + attr.targetPlatform().stringValue()); indent(-1); } -/* -@Override - public Void visitLazyValue(LazyValue_attribute attr, Void ignore) { - print("LazyValue: "); - constantWriter.write(attr.lazyvalue_index); - println(); - return null; - } -*/ case NestMembersAttribute attr -> { println("NestMembers:"); indent(+1);