8304542: Convert use of internal VM::classFileVersion to ClassFileFormatVersion

Reviewed-by: alanb
This commit is contained in:
Mandy Chung 2023-03-20 23:24:49 +00:00
parent f593a6b52e
commit bbca7c3ede
5 changed files with 14 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -27,9 +27,9 @@ package java.lang.invoke;
import jdk.internal.misc.CDS;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import sun.security.action.GetPropertyAction;
import java.lang.reflect.ClassFileFormatVersion;
import java.util.Properties;
import static java.lang.invoke.LambdaForm.basicTypeSignature;
@ -47,8 +47,7 @@ class MethodHandleStatics {
private MethodHandleStatics() { } // do not instantiate
static final Unsafe UNSAFE = Unsafe.getUnsafe();
static final int CLASSFILE_VERSION = VM.classFileVersion();
static final int CLASSFILE_VERSION = ClassFileFormatVersion.latest().major();
static final boolean DEBUG_METHOD_HANDLE_NAMES;
static final boolean DUMP_CLASS_FILES;
static final boolean TRACE_INTERPRETER;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -25,7 +25,6 @@
package java.lang.reflect;
import jdk.internal.misc.VM;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Label;
import jdk.internal.org.objectweb.asm.MethodVisitor;
@ -55,7 +54,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* "generateProxyClass" method.
*/
final class ProxyGenerator extends ClassWriter {
private static final int CLASSFILE_VERSION = VM.classFileVersion();
private static final int CLASSFILE_VERSION = ClassFileFormatVersion.latest().major();
private static final String JL_CLASS = "java/lang/Class";
private static final String JL_OBJECT = "java/lang/Object";
private static final String JL_THROWABLE = "java/lang/Throwable";

View File

@ -38,7 +38,6 @@ import jdk.internal.foreign.abi.Binding.Dup;
import jdk.internal.foreign.abi.Binding.UnboxAddress;
import jdk.internal.foreign.abi.Binding.VMLoad;
import jdk.internal.foreign.abi.Binding.VMStore;
import jdk.internal.misc.VM;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.ConstantDynamic;
@ -63,6 +62,7 @@ import java.lang.foreign.ValueLayout;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.ClassFileFormatVersion;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayDeque;
@ -81,7 +81,7 @@ public class BindingSpecializer {
= GetBooleanAction.privilegedGetProperty("jdk.internal.foreign.abi.Specializer.PERFORM_VERIFICATION");
// Bunch of helper constants
private static final int CLASSFILE_VERSION = VM.classFileVersion();
private static final int CLASSFILE_VERSION = ClassFileFormatVersion.latest().major();
private static final String OBJECT_DESC = Object.class.descriptorString();
private static final String OBJECT_INTRN = Type.getInternalName(Object.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -160,14 +160,6 @@ public class VM {
private static int classFileMinorVersion;
private static final int PREVIEW_MINOR_VERSION = 65535;
/**
* Returns the class file version of the current release.
* @jvms 4.1 Table 4.1-A. class file format major versions
*/
public static int classFileVersion() {
return classFileMajorVersion;
}
/**
* Tests if the given version is a supported {@code class}
* file version.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -39,6 +39,7 @@ import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
import java.lang.module.ResolvedModule;
import java.lang.reflect.ClassFileFormatVersion;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
@ -96,6 +97,8 @@ import jdk.tools.jlink.plugin.ResourcePoolEntry;
*/
public final class SystemModulesPlugin extends AbstractPlugin {
private static final int CLASSFILE_VERSION =
ClassFileFormatVersion.latest().major();
private static final String SYSTEM_MODULES_MAP_CLASS =
"jdk/internal/module/SystemModulesMap";
private static final String SYSTEM_MODULES_CLASS_PREFIX =
@ -590,7 +593,7 @@ public final class SystemModulesPlugin extends AbstractPlugin {
public ClassWriter getClassWriter(Configuration cf) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+ ClassWriter.COMPUTE_FRAMES);
cw.visit(Opcodes.V1_8,
cw.visit(CLASSFILE_VERSION,
ACC_FINAL+ACC_SUPER,
className,
null,
@ -1696,7 +1699,7 @@ public final class SystemModulesPlugin extends AbstractPlugin {
ResourcePoolBuilder out) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+ ClassWriter.COMPUTE_FRAMES);
cw.visit(Opcodes.V1_8,
cw.visit(CLASSFILE_VERSION,
ACC_FINAL+ACC_SUPER,
SYSTEM_MODULES_MAP_CLASS,
null,