< prev index next > src/java.base/share/classes/jdk/internal/classfile/impl/Util.java
Print this page
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2025, 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
import java.lang.classfile.*;
import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.classfile.components.ClassPrinter;
import java.lang.classfile.constantpool.ClassEntry;
+ import java.lang.classfile.constantpool.ConstantPool;
+ import java.lang.classfile.constantpool.ConstantPoolBuilder;
import java.lang.classfile.constantpool.ModuleEntry;
import java.lang.classfile.constantpool.PoolEntry;
import java.lang.classfile.constantpool.Utf8Entry;
import java.lang.constant.ClassDesc;
import java.lang.constant.MethodTypeDesc;
import jdk.internal.constant.ClassOrInterfaceDescImpl;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.Stable;
import static java.lang.classfile.ClassFile.ACC_STATIC;
+ import static java.lang.constant.ConstantDescs.INIT_NAME;
import static jdk.internal.constant.PrimitiveClassDescImpl.CD_double;
import static jdk.internal.constant.PrimitiveClassDescImpl.CD_long;
import static jdk.internal.constant.PrimitiveClassDescImpl.CD_void;
/**
public static boolean isDoubleSlot(ClassDesc desc) {
return desc == CD_double || desc == CD_long;
}
+ public static boolean checkConstantPoolsCompatible(ConstantPool one, ConstantPool two) {
+ if (one.equals(two))
+ return true;
+ if (one instanceof ConstantPoolBuilder cpb && cpb.canWriteDirect(two))
+ return true;
+ return two instanceof ConstantPoolBuilder cpb && cpb.canWriteDirect(one);
+ }
+
public static void dumpMethod(SplitConstantPool cp,
ClassDesc cls,
String methodName,
MethodTypeDesc methodDesc,
int acc,
}
dump.accept(" %02x".formatted(bytes[i]));
}
}
+ public static boolean canSkipMethodInflation(ClassReader cr, MethodInfo method, BufWriterImpl buf) {
+ if (!buf.canWriteDirect(cr)) {
+ return false;
+ }
+ if (method.methodName().equalsString(INIT_NAME) &&
+ !buf.strictFieldsMatch(((ClassReaderImpl) cr).getContainedClass())) {
+ return false;
+ }
+ return true;
+ }
+
public static void writeListIndices(BufWriter writer, List<? extends PoolEntry> list) {
writer.writeU2(list.size());
for (PoolEntry info : list) {
writer.writeIndex(info);
}
< prev index next >