Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 7ead8f4

Browse files
author
duke
committedAug 15, 2020
Automatic merge of client:master into master
2 parents 7a2831e + 9e29d3e commit 7ead8f4

File tree

7 files changed

+203
-120
lines changed

7 files changed

+203
-120
lines changed
 

‎src/hotspot/os/bsd/os_bsd.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -1536,21 +1536,37 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
15361536
int mib_kern[] = { CTL_KERN, KERN_OSTYPE };
15371537
if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) {
15381538
#ifdef __APPLE__
1539-
strncpy(os, "Darwin", sizeof(os));
1539+
strncpy(os, "Darwin", sizeof(os));
15401540
#elif __OpenBSD__
1541-
strncpy(os, "OpenBSD", sizeof(os));
1541+
strncpy(os, "OpenBSD", sizeof(os));
15421542
#else
1543-
strncpy(os, "BSD", sizeof(os));
1543+
strncpy(os, "BSD", sizeof(os));
15441544
#endif
15451545
}
15461546

15471547
char release[100];
15481548
size = sizeof(release);
15491549
int mib_release[] = { CTL_KERN, KERN_OSRELEASE };
15501550
if (sysctl(mib_release, 2, release, &size, NULL, 0) < 0) {
1551-
// if error, leave blank
1552-
strncpy(release, "", sizeof(release));
1551+
// if error, leave blank
1552+
strncpy(release, "", sizeof(release));
15531553
}
1554+
1555+
#ifdef __APPLE__
1556+
char osproductversion[100];
1557+
size_t sz = sizeof(osproductversion);
1558+
int ret = sysctlbyname("kern.osproductversion", osproductversion, &sz, NULL, 0);
1559+
if (ret == 0) {
1560+
char build[100];
1561+
size = sizeof(build);
1562+
int mib_build[] = { CTL_KERN, KERN_OSVERSION };
1563+
if (sysctl(mib_build, 2, build, &size, NULL, 0) < 0) {
1564+
snprintf(buf, buflen, "%s %s, macOS %s", os, release, osproductversion);
1565+
} else {
1566+
snprintf(buf, buflen, "%s %s, macOS %s (%s)", os, release, osproductversion, build);
1567+
}
1568+
} else
1569+
#endif
15541570
snprintf(buf, buflen, "%s %s", os, release);
15551571
}
15561572

‎src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,12 +33,6 @@
3333
class ShenandoahBarrierSetAssembler;
3434

3535
class ShenandoahBarrierSet: public BarrierSet {
36-
public:
37-
enum ArrayCopyStoreValMode {
38-
NONE,
39-
RESOLVE_BARRIER,
40-
EVAC_BARRIER
41-
};
4236
private:
4337

4438
ShenandoahHeap* _heap;

‎src/hotspot/share/interpreter/linkResolver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
339339

340340
// JDK 8, JVMS 5.4.3.4: Interface method resolution should
341341
// ignore static and non-public methods of java.lang.Object,
342-
// like clone, finalize, registerNatives.
342+
// like clone and finalize.
343343
if (in_imethod_resolve &&
344344
result != NULL &&
345345
ik->is_interface() &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2020, 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+
*/
23+
24+
/*
25+
// This jasm file implements the following java code:
26+
interface I { }
27+
28+
public class InterfaceObj implements I {
29+
static void f(I intf) throws Throwable {
30+
I.finalize();
31+
}
32+
public static void testFinalize() throws Throwable {
33+
f(new InterfaceObj());
34+
}
35+
static void c(I intf) throws Throwable {
36+
I.clone();
37+
}
38+
public static void testClone() throws Throwable {
39+
c(new InterfaceObj());
40+
}
41+
}
42+
*/
43+
44+
public interface I version 60:0 { } // end Class I
45+
46+
47+
super public class InterfaceObj implements I version 60:0 {
48+
49+
50+
public Method "<init>":"()V" stack 1 locals 1 {
51+
aload_0;
52+
invokespecial Method java/lang/Object."<init>":"()V";
53+
return;
54+
}
55+
56+
static Method f:"(LI;)V" throws java/lang/Throwable stack 1 locals 1 {
57+
aload_0;
58+
invokeinterface InterfaceMethod I.finalize:"()V", 1;
59+
return;
60+
}
61+
62+
public static Method testFinalize:"()V" throws java/lang/Throwable stack 2 locals 1 {
63+
new class InterfaceObj;
64+
dup;
65+
invokespecial Method "<init>":"()V";
66+
invokestatic Method f:"(LI;)V";
67+
return;
68+
}
69+
70+
static Method c:"(LI;)V" throws java/lang/Throwable stack 1 locals 1 {
71+
aload_0;
72+
invokeinterface InterfaceMethod I.clone:"()Ljava/lang/Object;", 1;
73+
return;
74+
}
75+
76+
public static Method testClone:"()V" throws java/lang/Throwable stack 2 locals 1 {
77+
new class InterfaceObj;
78+
dup;
79+
invokespecial Method "<init>":"()V";
80+
invokestatic Method c:"(LI;)V";
81+
return;
82+
}
83+
84+
} // end Class InterfaceObj

‎test/hotspot/jtreg/runtime/8026394/InterfaceObjectTest.java ‎test/hotspot/jtreg/runtime/linkResolver/InterfaceObjectTest.java

+33-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,10 @@
2323

2424
/*
2525
* @test
26-
* @bug 8026394
27-
* @summary clone() and finalize() interface resolution should not receive IAE
26+
* @bug 8026394 8251414
27+
* @summary test interface resolution when clone and finalize are declared abstract within
28+
* an interface and when they are not
29+
* @compile InterfaceObj.jasm
2830
* @run main InterfaceObjectTest
2931
*/
3032
interface IClone extends Cloneable {
@@ -54,16 +56,38 @@ public static void tryIt(ICloneExtend o1) {
5456
Object o2 = o1.clone();
5557
o1.finalize();
5658
} catch (Throwable t) {
57-
if (t instanceof IllegalAccessError) {
58-
System.out.println("TEST FAILS - IAE resulted\n");
59-
System.exit(1);
60-
}
59+
throw new AssertionError(t);
6160
}
6261
}
6362

64-
public static void main(String[] args) {
63+
64+
public static void main(String[] args) throws Exception {
65+
// Test with abstract public clone() and finalize() methods.
6566
InterfaceObjectTest o1 = new InterfaceObjectTest();
6667
tryIt(o1);
67-
System.out.println("TEST PASSES - no IAE resulted\n");
68+
69+
70+
// Test with reflection without abstract public clone() and finalize() methods.
71+
Class cls = Class.forName("InterfaceObj");
72+
try {
73+
java.lang.reflect.Method m = cls.getMethod("testFinalize");
74+
m.invoke(cls);
75+
throw new RuntimeException("Failed to throw NoSuchMethodError for finalize()");
76+
} catch (java.lang.reflect.InvocationTargetException e) {
77+
if (!e.getCause().toString().contains("NoSuchMethodError")) {
78+
throw new RuntimeException("wrong ITE: " + e.getCause().toString());
79+
}
80+
}
81+
82+
try {
83+
java.lang.reflect.Method m = cls.getMethod("testClone");
84+
m.invoke(cls);
85+
throw new RuntimeException("Failed to throw NoSuchMethodError for clone()");
86+
} catch (java.lang.reflect.InvocationTargetException e) {
87+
if (!e.getCause().toString().contains("NoSuchMethodError")) {
88+
throw new RuntimeException("wrong ITE: " + e.getCause().toString());
89+
}
90+
}
91+
6892
}
6993
}

‎test/jdk/java/io/File/GetXSpace.java

+63-16
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323

2424
/**
2525
* @test
26-
* @bug 4057701 6286712 6364377
27-
* @requires (os.family == "linux" | os.family == "mac" | os.family == "windows")
28-
* @run build GetXSpace
29-
* @run shell GetXSpace.sh
26+
* @bug 4057701 6286712 6364377 8181919
27+
* @requires (os.family == "linux" | os.family == "mac" |
28+
* os.family == "windows")
3029
* @summary Basic functionality of File.get-X-Space methods.
31-
* @key randomness
3230
*/
3331

3432
import java.io.BufferedReader;
@@ -38,11 +36,13 @@
3836
import java.io.IOException;
3937
import java.nio.file.Files;
4038
import java.nio.file.FileStore;
39+
import java.nio.file.Path;
4140
import java.security.Permission;
4241
import java.util.ArrayList;
4342
import java.util.regex.Matcher;
4443
import java.util.regex.Pattern;
4544

45+
import static java.lang.System.err;
4646
import static java.lang.System.out;
4747

4848
public class GetXSpace {
@@ -61,6 +61,12 @@ public class GetXSpace {
6161
private static int pass = 0;
6262
private static Throwable first;
6363

64+
static void reset() {
65+
fail = 0;
66+
pass = 0;
67+
first = null;
68+
}
69+
6470
static void pass() {
6571
pass++;
6672
}
@@ -338,7 +344,8 @@ public void checkRead(String file) {
338344
}
339345
}
340346

341-
private static void testFile(String dirName) {
347+
private static int testFile(Path dir) {
348+
String dirName = dir.toString();
342349
out.format("--- Testing %s%n", dirName);
343350
ArrayList<Space> l;
344351
try {
@@ -347,9 +354,18 @@ private static void testFile(String dirName) {
347354
throw new RuntimeException(dirName + " can't get file system information", x);
348355
}
349356
compare(l.get(0));
357+
358+
if (fail != 0) {
359+
err.format("%d tests: %d failure(s); first: %s%n",
360+
fail + pass, fail, first);
361+
} else {
362+
out.format("all %d tests passed%n", fail + pass);
363+
}
364+
365+
return fail != 0 ? 1 : 0;
350366
}
351367

352-
private static void testDF() {
368+
private static int testDF() {
353369
out.println("--- Testing df");
354370
// Find all of the partitions on the machine and verify that the size
355371
// returned by "df" is equivalent to File.getXSpace() values.
@@ -381,20 +397,51 @@ private static void testDF() {
381397
}
382398
}
383399
}
384-
}
385400

386-
public static void main(String [] args) {
387-
if (args.length > 0) {
388-
testFile(args[0]);
389-
} else {
390-
testDF();
391-
}
401+
System.setSecurityManager(null);
392402

393403
if (fail != 0) {
394-
throw new RuntimeException((fail + pass) + " tests: "
395-
+ fail + " failure(s), first", first);
404+
err.format("%d tests: %d failure(s); first: %s%n",
405+
fail + pass, fail, first);
396406
} else {
397407
out.format("all %d tests passed%n", fail + pass);
398408
}
409+
410+
return fail != 0 ? 1 : 0;
411+
}
412+
413+
private static void perms(File file, boolean allow) throws IOException {
414+
file.setExecutable(allow, false);
415+
file.setReadable(allow, false);
416+
file.setWritable(allow, false);
417+
}
418+
419+
private static void deny(Path path) throws IOException {
420+
perms(path.toFile(), false);
421+
}
422+
423+
private static void allow(Path path) throws IOException {
424+
perms(path.toFile(), true);
425+
}
426+
427+
public static void main(String[] args) throws Exception {
428+
int failedTests = testDF();
429+
reset();
430+
431+
Path tmpDir = Files.createTempDirectory(null);
432+
Path tmpSubdir = Files.createTempDirectory(tmpDir, null);
433+
Path tmpFile = Files.createTempFile(tmpSubdir, "foo", null);
434+
435+
deny(tmpSubdir);
436+
failedTests += testFile(tmpFile);
437+
438+
allow(tmpSubdir);
439+
Files.delete(tmpFile);
440+
Files.delete(tmpSubdir);
441+
Files.delete(tmpDir);
442+
443+
if (failedTests > 0) {
444+
throw new RuntimeException(failedTests + " test(s) failed");
445+
}
399446
}
400447
}

‎test/jdk/java/io/File/GetXSpace.sh

-82
This file was deleted.

0 commit comments

Comments
 (0)
This repository has been archived.