Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge
  • Loading branch information
prsadhuk committed Aug 15, 2020
2 parents 373e96d + 51cc98f commit 9e29d3e2513ce517171ab5b192b5089ac1013c7d
@@ -1536,21 +1536,37 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
int mib_kern[] = { CTL_KERN, KERN_OSTYPE };
if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) {
#ifdef __APPLE__
strncpy(os, "Darwin", sizeof(os));
strncpy(os, "Darwin", sizeof(os));
#elif __OpenBSD__
strncpy(os, "OpenBSD", sizeof(os));
strncpy(os, "OpenBSD", sizeof(os));
#else
strncpy(os, "BSD", sizeof(os));
strncpy(os, "BSD", sizeof(os));
#endif
}

char release[100];
size = sizeof(release);
int mib_release[] = { CTL_KERN, KERN_OSRELEASE };
if (sysctl(mib_release, 2, release, &size, NULL, 0) < 0) {
// if error, leave blank
strncpy(release, "", sizeof(release));
// if error, leave blank
strncpy(release, "", sizeof(release));
}

#ifdef __APPLE__
char osproductversion[100];
size_t sz = sizeof(osproductversion);
int ret = sysctlbyname("kern.osproductversion", osproductversion, &sz, NULL, 0);
if (ret == 0) {
char build[100];
size = sizeof(build);
int mib_build[] = { CTL_KERN, KERN_OSVERSION };
if (sysctl(mib_build, 2, build, &size, NULL, 0) < 0) {
snprintf(buf, buflen, "%s %s, macOS %s", os, release, osproductversion);
} else {
snprintf(buf, buflen, "%s %s, macOS %s (%s)", os, release, osproductversion, build);
}
} else
#endif
snprintf(buf, buflen, "%s %s", os, release);
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
* Copyright (c) 2013, 2020, Red Hat, Inc. 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
@@ -33,12 +33,6 @@
class ShenandoahBarrierSetAssembler;

class ShenandoahBarrierSet: public BarrierSet {
public:
enum ArrayCopyStoreValMode {
NONE,
RESOLVE_BARRIER,
EVAC_BARRIER
};
private:

ShenandoahHeap* _heap;
@@ -339,7 +339,7 @@ Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,

// JDK 8, JVMS 5.4.3.4: Interface method resolution should
// ignore static and non-public methods of java.lang.Object,
// like clone, finalize, registerNatives.
// like clone and finalize.
if (in_imethod_resolve &&
result != NULL &&
ik->is_interface() &&
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2020, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
// This jasm file implements the following java code:
interface I { }

public class InterfaceObj implements I {
static void f(I intf) throws Throwable {
I.finalize();
}
public static void testFinalize() throws Throwable {
f(new InterfaceObj());
}
static void c(I intf) throws Throwable {
I.clone();
}
public static void testClone() throws Throwable {
c(new InterfaceObj());
}
}
*/

public interface I version 60:0 { } // end Class I


super public class InterfaceObj implements I version 60:0 {


public Method "<init>":"()V" stack 1 locals 1 {
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}

static Method f:"(LI;)V" throws java/lang/Throwable stack 1 locals 1 {
aload_0;
invokeinterface InterfaceMethod I.finalize:"()V", 1;
return;
}

public static Method testFinalize:"()V" throws java/lang/Throwable stack 2 locals 1 {
new class InterfaceObj;
dup;
invokespecial Method "<init>":"()V";
invokestatic Method f:"(LI;)V";
return;
}

static Method c:"(LI;)V" throws java/lang/Throwable stack 1 locals 1 {
aload_0;
invokeinterface InterfaceMethod I.clone:"()Ljava/lang/Object;", 1;
return;
}

public static Method testClone:"()V" throws java/lang/Throwable stack 2 locals 1 {
new class InterfaceObj;
dup;
invokespecial Method "<init>":"()V";
invokestatic Method c:"(LI;)V";
return;
}

} // end Class InterfaceObj
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
@@ -23,8 +23,10 @@

/*
* @test
* @bug 8026394
* @summary clone() and finalize() interface resolution should not receive IAE
* @bug 8026394 8251414
* @summary test interface resolution when clone and finalize are declared abstract within
* an interface and when they are not
* @compile InterfaceObj.jasm
* @run main InterfaceObjectTest
*/
interface IClone extends Cloneable {
@@ -54,16 +56,38 @@ public static void tryIt(ICloneExtend o1) {
Object o2 = o1.clone();
o1.finalize();
} catch (Throwable t) {
if (t instanceof IllegalAccessError) {
System.out.println("TEST FAILS - IAE resulted\n");
System.exit(1);
}
throw new AssertionError(t);
}
}

public static void main(String[] args) {

public static void main(String[] args) throws Exception {
// Test with abstract public clone() and finalize() methods.
InterfaceObjectTest o1 = new InterfaceObjectTest();
tryIt(o1);
System.out.println("TEST PASSES - no IAE resulted\n");


// Test with reflection without abstract public clone() and finalize() methods.
Class cls = Class.forName("InterfaceObj");
try {
java.lang.reflect.Method m = cls.getMethod("testFinalize");
m.invoke(cls);
throw new RuntimeException("Failed to throw NoSuchMethodError for finalize()");
} catch (java.lang.reflect.InvocationTargetException e) {
if (!e.getCause().toString().contains("NoSuchMethodError")) {
throw new RuntimeException("wrong ITE: " + e.getCause().toString());
}
}

try {
java.lang.reflect.Method m = cls.getMethod("testClone");
m.invoke(cls);
throw new RuntimeException("Failed to throw NoSuchMethodError for clone()");
} catch (java.lang.reflect.InvocationTargetException e) {
if (!e.getCause().toString().contains("NoSuchMethodError")) {
throw new RuntimeException("wrong ITE: " + e.getCause().toString());
}
}

}
}
@@ -23,12 +23,10 @@

/**
* @test
* @bug 4057701 6286712 6364377
* @requires (os.family == "linux" | os.family == "mac" | os.family == "windows")
* @run build GetXSpace
* @run shell GetXSpace.sh
* @bug 4057701 6286712 6364377 8181919
* @requires (os.family == "linux" | os.family == "mac" |
* os.family == "windows")
* @summary Basic functionality of File.get-X-Space methods.
* @key randomness
*/

import java.io.BufferedReader;
@@ -38,11 +36,13 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.FileStore;
import java.nio.file.Path;
import java.security.Permission;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.System.err;
import static java.lang.System.out;

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

static void reset() {
fail = 0;
pass = 0;
first = null;
}

static void pass() {
pass++;
}
@@ -338,7 +344,8 @@ public void checkRead(String file) {
}
}

private static void testFile(String dirName) {
private static int testFile(Path dir) {
String dirName = dir.toString();
out.format("--- Testing %s%n", dirName);
ArrayList<Space> l;
try {
@@ -347,9 +354,18 @@ private static void testFile(String dirName) {
throw new RuntimeException(dirName + " can't get file system information", x);
}
compare(l.get(0));

if (fail != 0) {
err.format("%d tests: %d failure(s); first: %s%n",
fail + pass, fail, first);
} else {
out.format("all %d tests passed%n", fail + pass);
}

return fail != 0 ? 1 : 0;
}

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

public static void main(String [] args) {
if (args.length > 0) {
testFile(args[0]);
} else {
testDF();
}
System.setSecurityManager(null);

if (fail != 0) {
throw new RuntimeException((fail + pass) + " tests: "
+ fail + " failure(s), first", first);
err.format("%d tests: %d failure(s); first: %s%n",
fail + pass, fail, first);
} else {
out.format("all %d tests passed%n", fail + pass);
}

return fail != 0 ? 1 : 0;
}

private static void perms(File file, boolean allow) throws IOException {
file.setExecutable(allow, false);
file.setReadable(allow, false);
file.setWritable(allow, false);
}

private static void deny(Path path) throws IOException {
perms(path.toFile(), false);
}

private static void allow(Path path) throws IOException {
perms(path.toFile(), true);
}

public static void main(String[] args) throws Exception {
int failedTests = testDF();
reset();

Path tmpDir = Files.createTempDirectory(null);
Path tmpSubdir = Files.createTempDirectory(tmpDir, null);
Path tmpFile = Files.createTempFile(tmpSubdir, "foo", null);

deny(tmpSubdir);
failedTests += testFile(tmpFile);

allow(tmpSubdir);
Files.delete(tmpFile);
Files.delete(tmpSubdir);
Files.delete(tmpDir);

if (failedTests > 0) {
throw new RuntimeException(failedTests + " test(s) failed");
}
}
}

0 comments on commit 9e29d3e

Please sign in to comment.