Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixes
  • Loading branch information
liach committed Sep 25, 2025
commit fc52cd9e1c895eefddbebfc443a242455a805c11
7 changes: 5 additions & 2 deletions src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand Down Expand Up @@ -42,6 +42,9 @@
import java.lang.classfile.attribute.EnclosingMethodAttribute;
import java.lang.classfile.attribute.InnerClassesAttribute;

import static java.lang.classfile.ClassFile.ACC_PROTECTED;
import static java.lang.classfile.ClassFile.ACC_PUBLIC;

/**
* A FingerPrint is an abstract representation of a JarFile entry that contains
* information to determine if the entry represents a class or a
Expand Down Expand Up @@ -316,7 +319,7 @@ public void accept(ClassElement cle) {
}

private static boolean isPublic(AccessFlags access) {
return access.has(AccessFlag.PUBLIC) || access.has(AccessFlag.PROTECTED);
return (access.flagsMask() & (ACC_PUBLIC | ACC_PROTECTED)) != 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand Down
13 changes: 6 additions & 7 deletions test/jdk/java/lang/Class/getSimpleName/GetSimpleNameTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down Expand Up @@ -37,8 +37,7 @@
import java.lang.reflect.AccessFlag;
import java.util.Optional;

import static java.lang.classfile.ClassFile.ACC_PUBLIC;
import static java.lang.classfile.ClassFile.ACC_STATIC;
import static java.lang.classfile.ClassFile.*;
import static java.lang.constant.ConstantDescs.CD_Object;
import static java.lang.constant.ConstantDescs.INIT_NAME;
import static java.lang.constant.ConstantDescs.MTD_void;
Expand Down Expand Up @@ -167,7 +166,7 @@ byte[] getNestedClasses(boolean isInner) {
var name = (isInner ? innerName : outerName);
return ClassFile.of().build(name, clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.with(InnerClassesAttribute.of(
InnerClassInfo.of(innerName,
Optional.of(outerName),
Expand All @@ -180,7 +179,7 @@ byte[] getInnerClasses(boolean isInner) {
var name = (isInner ? innerName : outerName);
return ClassFile.of().build(name, clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.with(InnerClassesAttribute.of(
InnerClassInfo.of(innerName,
Optional.of(outerName),
Expand All @@ -194,7 +193,7 @@ byte[] getLocalClasses(boolean isInner) {
var name = (isInner ? innerName : outerName);
return ClassFile.of().build(name, clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.with(InnerClassesAttribute.of(
InnerClassInfo.of(innerName,
Optional.empty(),
Expand All @@ -209,7 +208,7 @@ byte[] getAnonymousClasses(boolean isInner) {
var name = (isInner ? innerName : outerName);
return ClassFile.of().build(name, clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.with(InnerClassesAttribute.of(
InnerClassInfo.of(innerName,
Optional.empty(),
Expand Down
11 changes: 5 additions & 6 deletions test/jdk/java/lang/invoke/DefineClassTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
Expand Down Expand Up @@ -41,8 +41,7 @@
import java.nio.file.Paths;
import org.testng.annotations.Test;

import static java.lang.classfile.ClassFile.ACC_PUBLIC;
import static java.lang.classfile.ClassFile.ACC_STATIC;
import static java.lang.classfile.ClassFile.*;
import static java.lang.constant.ConstantDescs.CD_Object;
import static java.lang.constant.ConstantDescs.CLASS_INIT_NAME;
import static java.lang.constant.ConstantDescs.INIT_NAME;
Expand Down Expand Up @@ -259,7 +258,7 @@ public void testModuleInfo() throws Exception {
*/
byte[] generateClass(String className) {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withSuperclass(CD_Object);
clb.withMethodBody(INIT_NAME, MTD_void, PUBLIC, cob -> {
cob.aload(0);
Expand Down Expand Up @@ -301,7 +300,7 @@ byte[] generateClassWithInitializer(String className,
String targetMethod) throws Exception {

return ClassFile.of().build(ClassDesc.of(className), clb -> {
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withSuperclass(CD_Object);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
Expand All @@ -320,7 +319,7 @@ byte[] generateClassWithInitializer(String className,
*/
byte[] generateNonLinkableClass(String className) {
return ClassFile.of().build(ClassDesc.of(className), clb -> {
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withSuperclass(CD_MissingSuperClass);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 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
Expand Down Expand Up @@ -41,8 +41,7 @@
import java.lang.reflect.AccessFlag;
import org.testng.annotations.Test;

import static java.lang.classfile.ClassFile.ACC_PUBLIC;
import static java.lang.classfile.ClassFile.ACC_STATIC;
import static java.lang.classfile.ClassFile.*;
import static java.lang.constant.ConstantDescs.CD_Object;
import static java.lang.constant.ConstantDescs.CD_int;
import static java.lang.constant.ConstantDescs.INIT_NAME;
Expand Down Expand Up @@ -117,7 +116,7 @@ private static void test(String pkg) throws Throwable {
public static byte[] dumpClass(String pkg) {
return ClassFile.of().build(ClassDesc.of(pkg.replace('/', '.'), "MyClass"), clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withMethodBody(INIT_NAME, MTD_void, 0, cob -> {
cob.aload(0);
cob.invokespecial(CD_Object, INIT_NAME, MTD_void);
Expand Down
11 changes: 5 additions & 6 deletions test/jdk/java/lang/invoke/lookup/SpecialStatic.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
Expand Down Expand Up @@ -41,8 +41,7 @@

import org.testng.annotations.*;

import static java.lang.classfile.ClassFile.ACC_PUBLIC;
import static java.lang.classfile.ClassFile.ACC_STATIC;
import static java.lang.classfile.ClassFile.*;
import static java.lang.constant.ConstantDescs.*;
import static java.lang.constant.DirectMethodHandleDesc.Kind.SPECIAL;
import static org.testng.Assert.*;
Expand Down Expand Up @@ -120,7 +119,7 @@ public void testFindSpecial() throws Throwable {
public static byte[] dumpT1() {
return ClassFile.of().build(CD_T1, clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_Object, INIT_NAME, MTD_void);
Expand All @@ -136,7 +135,7 @@ public static byte[] dumpT1() {
public static byte[] dumpT2() {
return ClassFile.of().build(CD_T2, clb -> {
clb.withSuperclass(CD_T1);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_T1, INIT_NAME, MTD_void);
Expand All @@ -152,7 +151,7 @@ public static byte[] dumpT2() {
public static byte[] dumpT3() {
return ClassFile.of().build(CD_T3, clb -> {
clb.withSuperclass(CD_T2);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);
clb.withMethodBody(INIT_NAME, MTD_void, ACC_PUBLIC, cob -> {
cob.aload(0);
cob.invokespecial(CD_T2, INIT_NAME, MTD_void);
Expand Down
7 changes: 3 additions & 4 deletions test/jdk/java/util/ServiceLoader/BadProvidersTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand Down Expand Up @@ -54,8 +54,7 @@
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;

import static java.lang.classfile.ClassFile.ACC_PUBLIC;
import static java.lang.classfile.ClassFile.ACC_STATIC;
import static java.lang.classfile.ClassFile.*;
import static java.lang.constant.ConstantDescs.CD_Object;
import static java.lang.constant.ConstantDescs.INIT_NAME;
import static java.lang.constant.ConstantDescs.MTD_void;
Expand Down Expand Up @@ -216,7 +215,7 @@ public void testWithTwoFactoryMethods() throws Exception {

var bytes = ClassFile.of().build(ClassDesc.of("p", "ProviderFactory"), clb -> {
clb.withSuperclass(CD_Object);
clb.withFlags(AccessFlag.PUBLIC, AccessFlag.IDENTITY);
clb.withFlags(ACC_PUBLIC | ACC_IDENTITY);

var providerFactory$1 = ClassDesc.of("p", "ProviderFactory$1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import tools.javac.combo.CompilationTestCase;
import toolbox.ToolBox;

import static java.lang.classfile.ClassFile.*;

class ValueObjectCompilationTests extends CompilationTestCase {

private static String[] PREVIEW_OPTIONS = {
Expand Down Expand Up @@ -644,7 +646,8 @@ abstract class Inner {}
for (final File fileEntry : dir.listFiles()) {
if (fileEntry.getName().contains("$")) {
var classFile = ClassFile.of().parse(fileEntry.toPath());
Assert.check(classFile.flags().has(AccessFlag.IDENTITY));
// Check bit, these classes may be non-preview
Assert.check((classFile.flags().flagsMask() & ACC_IDENTITY) != 0);
}
}
}
Expand Down Expand Up @@ -689,7 +692,8 @@ record R() {}
File dir = assertOK(true, source);
for (final File fileEntry : dir.listFiles()) {
var classFile = ClassFile.of().parse(fileEntry.toPath());
Assert.check(classFile.flags().has(AccessFlag.IDENTITY));
// Check bit, these classes may be non-preview
Assert.check((classFile.flags().flagsMask() & ACC_IDENTITY) != 0);
}
}

Expand Down Expand Up @@ -766,12 +770,12 @@ class Test {
File dir = assertOK(true, source);
for (final File fileEntry : dir.listFiles()) {
var classFile = ClassFile.of().parse(fileEntry.toPath());
Assert.check(classFile.flags().has(AccessFlag.IDENTITY));
// Check bit, these classes may be non-preview
Assert.check((classFile.flags().flagsMask() & ACC_IDENTITY) != 0);
for (var field : classFile.fields()) {
if (!field.flags().has(AccessFlag.STATIC)) {
Set<AccessFlag> fieldFlags = field.flags().flags();
Assert.check(fieldFlags.contains(AccessFlag.STRICT_INIT));
}
// TODO migrate to AccessFlag when javac correctly sets preview version
int mask = field.flags().flagsMask();
Assert.check((mask & ACC_STATIC) != 0 || (mask & ACC_STRICT_INIT) != 0);
}
}
}
Expand Down