1 /*
2 * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
171 ReferenceType refType = debugee.classByName(className);
172 if (refType == null) {
173 logHandler.complain("##> isPublic001: Could NOT FIND class: " + className);
174 class_not_found_errors++;
175 continue;
176 }
177 Class class_obj;
178 try {
179 class_obj = Class.forName(className);
180 }
181 catch (ClassNotFoundException e) {
182 logHandler.complain
183 ("##> modifiers001: Class.forName("+className+") - "+e.toString());
184 class_not_found_exceptions++;
185 continue;
186 }
187 int expected_modifiers = class_obj.getModifiers();
188 String s_type = classes_for_check[i][2];
189 String s_modifiers = classes_for_check[i][1];
190 int got_modifiers = refType.modifiers();
191 // Class.getModifiers() will never return ACC_SUPER
192 // but Accessible.modifers() can, so ignore this bit
193 got_modifiers &= ~0x20; // 0x20 == ACC_SUPER
194 logHandler.display("");
195 if ( got_modifiers != expected_modifiers ) {
196 logHandler.complain("##> modifiers001: UNEXPECTED modifiers() method result ("
197 + "0x" + Integer.toHexString(got_modifiers) + ") for " + s_type + ": " + className
198 + "(" + s_modifiers + ")");
199 logHandler.complain("##> expected modifiers() method result = "
200 + "0x" + Integer.toHexString(expected_modifiers));
201 modifiers_method_errors++;
202 }
203 else {
204 print_log_on_verbose("--> modifiers001: expected modifiers() method result ("
205 + "0x" + Integer.toHexString(got_modifiers) + ") for " + s_type + ": " + className
206 + "(" + s_modifiers + ")");
207 }
208 }
209 logHandler.display
210 ("--> modifiers001: checking debugee's classes completed!");
211 logHandler.display
212 ("--> modifiers001: number of checked classes = " + all_classes_count);
213 if ( class_not_found_errors > 0 ) {
|
1 /*
2 * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
171 ReferenceType refType = debugee.classByName(className);
172 if (refType == null) {
173 logHandler.complain("##> isPublic001: Could NOT FIND class: " + className);
174 class_not_found_errors++;
175 continue;
176 }
177 Class class_obj;
178 try {
179 class_obj = Class.forName(className);
180 }
181 catch (ClassNotFoundException e) {
182 logHandler.complain
183 ("##> modifiers001: Class.forName("+className+") - "+e.toString());
184 class_not_found_exceptions++;
185 continue;
186 }
187 int expected_modifiers = class_obj.getModifiers();
188 String s_type = classes_for_check[i][2];
189 String s_modifiers = classes_for_check[i][1];
190 int got_modifiers = refType.modifiers();
191 boolean previewEnabled =
192 System.getProperty("test.java.opts", "").contains("--enable-preview") ||
193 System.getProperty("test.vm.opts", "").contains("--enable-preview");
194 if (!previewEnabled) {
195 // With preview enabled 0x20 is ACC_IDENTITY.
196 // When not enabled 0x20 is ACC_SUPER.
197 // Class.getModifiers() will never return ACC_SUPER
198 // but Accessible.modifers() can, so ignore this bit.
199 got_modifiers &= ~0x20; // 0x20 == ACC_SUPER
200 }
201 logHandler.display("");
202 if ( got_modifiers != expected_modifiers ) {
203 logHandler.complain("##> modifiers001: UNEXPECTED modifiers() method result ("
204 + "0x" + Integer.toHexString(got_modifiers) + ") for " + s_type + ": " + className
205 + "(" + s_modifiers + ")");
206 logHandler.complain("##> expected modifiers() method result = "
207 + "0x" + Integer.toHexString(expected_modifiers));
208 modifiers_method_errors++;
209 }
210 else {
211 print_log_on_verbose("--> modifiers001: expected modifiers() method result ("
212 + "0x" + Integer.toHexString(got_modifiers) + ") for " + s_type + ": " + className
213 + "(" + s_modifiers + ")");
214 }
215 }
216 logHandler.display
217 ("--> modifiers001: checking debugee's classes completed!");
218 logHandler.display
219 ("--> modifiers001: number of checked classes = " + all_classes_count);
220 if ( class_not_found_errors > 0 ) {
|