This commit is contained in:
Jesper Wilhelmsson 2017-11-11 01:21:09 +01:00
commit fdee542113
654 changed files with 12550 additions and 7320 deletions

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 1996, 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT __attribute__((visibility("default")))
#define JNICALL
typedef int jint;
#ifdef _LP64 /* 64-bit */
typedef long jlong;
#else
typedef long long jlong;
#endif
typedef signed char jbyte;
#endif /* !_JAVASOFT_JNI_MD_H_ */

View file

@ -1,80 +0,0 @@
/*
* Copyright (c) 1997, 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
#ifndef _JAVASOFT_JVM_MD_H_
#define _JAVASOFT_JVM_MD_H_
/*
* This file is currently collecting system-specific dregs for the
* JNI conversion, which should be sorted out later.
*/
#include <dirent.h> /* For DIR */
#include <sys/param.h> /* For MAXPATHLEN */
#include <unistd.h> /* For F_OK, R_OK, W_OK */
#include <stddef.h> /* For ptrdiff_t */
#include <stdint.h> /* For uintptr_t */
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}
#define JNI_LIB_PREFIX "lib"
#define JNI_LIB_SUFFIX ".dylib"
#define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME "." VERSION JNI_LIB_SUFFIX
#define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX
#define JVM_MAXPATHLEN MAXPATHLEN
#define JVM_R_OK R_OK
#define JVM_W_OK W_OK
#define JVM_X_OK X_OK
#define JVM_F_OK F_OK
/*
* File I/O
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
/* O Flags */
#define JVM_O_RDONLY O_RDONLY
#define JVM_O_WRONLY O_WRONLY
#define JVM_O_RDWR O_RDWR
#define JVM_O_O_APPEND O_APPEND
#define JVM_O_EXCL O_EXCL
#define JVM_O_CREAT O_CREAT
/* Signals */
#define JVM_SIGINT SIGINT
#define JVM_SIGTERM SIGTERM
#endif /* !_JAVASOFT_JVM_MD_H_ */

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -32,14 +32,12 @@ import java.lang.StackWalker.StackFrame;
import java.lang.invoke.MethodType;
class StackFrameInfo implements StackFrame {
private final byte RETAIN_CLASS_REF = 0x01;
private final static JavaLangInvokeAccess JLIA =
SharedSecrets.getJavaLangInvokeAccess();
// Footprint improvement: MemberName::clazz can replace
// StackFrameInfo::declaringClass.
private final StackWalker walker;
private final Class<?> declaringClass;
private final byte flags;
private final Object memberName;
private final short bci;
private volatile StackTraceElement ste;
@ -49,8 +47,7 @@ class StackFrameInfo implements StackFrame {
* to use
*/
StackFrameInfo(StackWalker walker) {
this.walker = walker;
this.declaringClass = null;
this.flags = walker.retainClassRef ? RETAIN_CLASS_REF : 0;
this.bci = -1;
this.memberName = JLIA.newMemberName();
}
@ -58,20 +55,20 @@ class StackFrameInfo implements StackFrame {
// package-private called by StackStreamFactory to skip
// the capability check
Class<?> declaringClass() {
return declaringClass;
return JLIA.getDeclaringClass(memberName);
}
// ----- implementation of StackFrame methods
@Override
public String getClassName() {
return declaringClass.getName();
return declaringClass().getName();
}
@Override
public Class<?> getDeclaringClass() {
walker.ensureAccessEnabled(RETAIN_CLASS_REFERENCE);
return declaringClass;
ensureRetainClassRefEnabled();
return declaringClass();
}
@Override
@ -81,7 +78,7 @@ class StackFrameInfo implements StackFrame {
@Override
public MethodType getMethodType() {
walker.ensureAccessEnabled(RETAIN_CLASS_REFERENCE);
ensureRetainClassRefEnabled();
return JLIA.getMethodType(memberName);
}
@ -137,4 +134,10 @@ class StackFrameInfo implements StackFrame {
}
return s;
}
private void ensureRetainClassRefEnabled() {
if ((flags & RETAIN_CLASS_REF) == 0) {
throw new UnsupportedOperationException("No access to RETAIN_CLASS_REFERENCE");
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -296,6 +296,7 @@ public final class StackWalker {
private final Set<Option> options;
private final ExtendedOption extendedOption;
private final int estimateDepth;
final boolean retainClassRef; // cached for performance
/**
* Returns a {@code StackWalker} instance.
@ -412,6 +413,7 @@ public final class StackWalker {
this.options = options;
this.estimateDepth = estimateDepth;
this.extendedOption = extendedOption;
this.retainClassRef = hasOption(Option.RETAIN_CLASS_REFERENCE);
}
private static void checkPermission(Set<Option> options) {
@ -590,7 +592,7 @@ public final class StackWalker {
*/
@CallerSensitive
public Class<?> getCallerClass() {
if (!options.contains(Option.RETAIN_CLASS_REFERENCE)) {
if (!retainClassRef) {
throw new UnsupportedOperationException("This stack walker " +
"does not have RETAIN_CLASS_REFERENCE access");
}
@ -617,11 +619,4 @@ public final class StackWalker {
boolean hasLocalsOperandsOption() {
return extendedOption == ExtendedOption.LOCALS_AND_OPERANDS;
}
void ensureAccessEnabled(Option access) {
if (!hasOption(access)) {
throw new UnsupportedOperationException("No access to " + access +
": " + options.toString());
}
}
}

View file

@ -1784,6 +1784,11 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
MemberName memberName = (MemberName)mname;
return memberName.getName();
}
@Override
public Class<?> getDeclaringClass(Object mname) {
MemberName memberName = (MemberName)mname;
return memberName.getDeclaringClass();
}
@Override
public MethodType getMethodType(Object mname) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -30,33 +30,39 @@ import java.util.Map;
public interface JavaLangInvokeAccess {
/**
* Create a new MemberName instance. Used by {@see StackFrameInfo}.
* Create a new MemberName instance. Used by {@code StackFrameInfo}.
*/
Object newMemberName();
/**
* Returns the name for the given MemberName. Used by {@see StackFrameInfo}.
* Returns the name for the given MemberName. Used by {@code StackFrameInfo}.
*/
String getName(Object mname);
/**
* Returns the {@code MethodType} for the given MemberName.
* Used by {@see StackFrameInfo}.
* Used by {@code StackFrameInfo}.
*/
MethodType getMethodType(Object mname);
/**
* Returns the descriptor for the given MemberName.
* Used by {@see StackFrameInfo}.
* Used by {@code StackFrameInfo}.
*/
String getMethodDescriptor(Object mname);
/**
* Returns {@code true} if the given MemberName is a native method. Used by
* {@see StackFrameInfo}.
* Returns {@code true} if the given MemberName is a native method.
* Used by {@code StackFrameInfo}.
*/
boolean isNative(Object mname);
/**
* Returns the declaring class for the given MemberName.
* Used by {@code StackFrameInfo}.
*/
Class<?> getDeclaringClass(Object mname);
/**
* Returns a {@code byte[]} representation of a class implementing
* DirectMethodHandle of each pairwise combination of {@code MethodType} and

View file

@ -54,9 +54,29 @@ enum {
JVM_ACC_STRICT = 0x0800,
JVM_ACC_SYNTHETIC = 0x1000,
JVM_ACC_ANNOTATION = 0x2000,
JVM_ACC_ENUM = 0x4000
JVM_ACC_ENUM = 0x4000,
JVM_ACC_MODULE = 0x8000
};
#define JVM_ACC_PUBLIC_BIT 0
#define JVM_ACC_PRIVATE_BIT 1
#define JVM_ACC_PROTECTED_BIT 2
#define JVM_ACC_STATIC_BIT 3
#define JVM_ACC_FINAL_BIT 4
#define JVM_ACC_SYNCHRONIZED_BIT 5
#define JVM_ACC_SUPER_BIT 5
#define JVM_ACC_VOLATILE_BIT 6
#define JVM_ACC_BRIDGE_BIT 6
#define JVM_ACC_TRANSIENT_BIT 7
#define JVM_ACC_VARARGS_BIT 7
#define JVM_ACC_NATIVE_BIT 8
#define JVM_ACC_INTERFACE_BIT 9
#define JVM_ACC_ABSTRACT_BIT 10
#define JVM_ACC_STRICT_BIT 11
#define JVM_ACC_SYNTHETIC_BIT 12
#define JVM_ACC_ANNOTATION_BIT 13
#define JVM_ACC_ENUM_BIT 14
/* Used in newarray instruction. */
enum {
@ -86,8 +106,9 @@ enum {
JVM_CONSTANT_InterfaceMethodref = 11,
JVM_CONSTANT_NameAndType = 12,
JVM_CONSTANT_MethodHandle = 15, // JSR 292
JVM_CONSTANT_MethodType = 16, // JSR 292
JVM_CONSTANT_InvokeDynamic = 18
JVM_CONSTANT_MethodType = 16, // JSR 292
JVM_CONSTANT_InvokeDynamic = 18,
JVM_CONSTANT_ExternalMax = 18
};
/* JVM_CONSTANT_MethodHandle subtypes */

View file

@ -1155,20 +1155,25 @@ JVM_NativePath(char *);
* be renamed to JVM_* in the future?
*/
/*
* BE CAREFUL! The following functions do not implement the
* full feature set of standard C printf formats.
*/
int
/* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3),
* respectively, with the following differences:
* - The string written to str is always zero-terminated, also in case of
* truncation (count is too small to hold the result string), unless count
* is 0. In case of truncation count-1 characters are written and '\0'
* appendend.
* - If count is too small to hold the whole string, -1 is returned across
* all platforms. */
JNIEXPORT int
jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
int
JNIEXPORT int
jio_snprintf(char *str, size_t count, const char *fmt, ...);
int
JNIEXPORT int
jio_fprintf(FILE *, const char *fmt, ...);
int
JNIEXPORT int
jio_vfprintf(FILE *, const char *fmt, va_list args);

View file

@ -37,7 +37,7 @@
#include <dlfcn.h>
#include <thread.h>
#include <synch.h>
#include "jvm_solaris.h"
#include "jvm_md.h"
#define bool int
#define true 1

View file

@ -30,8 +30,13 @@
#define __has_attribute(x) 0
#endif
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT __attribute__((visibility("default")))
#ifdef ARM
#define JNIEXPORT __attribute__((externally_visible,visibility("default")))
#define JNIIMPORT __attribute__((externally_visible,visibility("default")))
#else
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT __attribute__((visibility("default")))
#endif
#else
#define JNIEXPORT
#define JNIIMPORT
@ -40,7 +45,7 @@
#define JNICALL
typedef int jint;
#ifdef _LP64 /* 64-bit Solaris */
#ifdef _LP64
typedef long jlong;
#else
typedef long long jlong;

View file

@ -39,6 +39,10 @@
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}
#define JVM_ONLOAD_SYMBOLS {"JVM_OnLoad"}
#define AGENT_ONLOAD_SYMBOLS {"Agent_OnLoad"}
#define AGENT_ONUNLOAD_SYMBOLS {"Agent_OnUnload"}
#define AGENT_ONATTACH_SYMBOLS {"Agent_OnAttach"}
#define JNI_LIB_PREFIX "lib"
#ifdef __APPLE__
@ -50,7 +54,15 @@
#endif
#define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX
#if defined(AIX) || defined(SOLARIS)
#define JVM_MAXPATHLEN MAXPATHLEN
#else
// Hack: MAXPATHLEN is 4095 on some Linux and 4096 on others. This may
// cause problems if JVM and the rest of JDK are built on different
// Linux releases. Here we define JVM_MAXPATHLEN to be MAXPATHLEN + 1,
// so buffers declared in VM are always >= 4096.
#define JVM_MAXPATHLEN MAXPATHLEN + 1
#endif
#define JVM_R_OK R_OK
#define JVM_W_OK W_OK
@ -67,19 +79,22 @@
#include <errno.h>
#include <signal.h>
/* O Flags */
#define JVM_O_RDONLY O_RDONLY
#define JVM_O_WRONLY O_WRONLY
#define JVM_O_RDWR O_RDWR
#define JVM_O_O_APPEND O_APPEND
#define JVM_O_EXCL O_EXCL
#define JVM_O_CREAT O_CREAT
/* Signals */
#include <sys/socket.h> // for socklen_t
#define JVM_SIGINT SIGINT
#define JVM_SIGTERM SIGTERM
#define BREAK_SIGNAL SIGQUIT /* Thread dumping support. */
#ifdef SOLARIS
#define ASYNC_SIGNAL SIGJVM2 /* Event-based suspend/resume support */
#endif // SOLARIS
#define SHUTDOWN1_SIGNAL SIGHUP /* Shutdown Hooks support. */
#define SHUTDOWN2_SIGNAL SIGINT
#define SHUTDOWN3_SIGNAL SIGTERM
/* With 1.4.1 libjsig added versioning: used in os_solaris.cpp and jsig.c */
#define JSIG_VERSION_1_4_1 0x30140100
#endif /* !_JAVASOFT_JVM_MD_H_ */

View file

@ -38,11 +38,13 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include "jni.h"
#include "jni_util.h"
#include "jlong.h"
#include "jvm.h"
#include "io_util.h"
#include "io_util_md.h"
#include "java_io_FileSystem.h"
@ -97,9 +99,9 @@ Java_java_io_UnixFileSystem_canonicalize0(JNIEnv *env, jobject this,
jstring rv = NULL;
WITH_PLATFORM_STRING(env, pathname, path) {
char canonicalPath[JVM_MAXPATHLEN];
char canonicalPath[PATH_MAX];
if (canonicalize((char *)path,
canonicalPath, JVM_MAXPATHLEN) < 0) {
canonicalPath, PATH_MAX) < 0) {
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
} else {
#ifdef MACOSX

View file

@ -30,6 +30,7 @@
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall
// 'long' is always 32 bit on windows so this matches what jdk expects
typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;

View file

@ -31,13 +31,20 @@
* JNI conversion, which should be sorted out later.
*/
#include <windows.h>
#include <windef.h>
#include <winbase.h>
#include "jni.h"
typedef int socklen_t;
#define JNI_ONLOAD_SYMBOLS {"_JNI_OnLoad@8", "JNI_OnLoad"}
#define JNI_ONUNLOAD_SYMBOLS {"_JNI_OnUnload@8", "JNI_OnUnload"}
#define JVM_ONLOAD_SYMBOLS {"_JVM_OnLoad@12", "JVM_OnLoad"}
#define AGENT_ONLOAD_SYMBOLS {"_Agent_OnLoad@12", "Agent_OnLoad"}
#define AGENT_ONUNLOAD_SYMBOLS {"_Agent_OnUnload@4", "Agent_OnUnload"}
#define AGENT_ONATTACH_SYMBOLS {"_Agent_OnAttach@12", "Agent_OnAttach"}
#define JNI_LIB_PREFIX ""
#define JNI_LIB_SUFFIX ".dll"
@ -63,21 +70,16 @@ typedef struct {
#define JVM_X_OK 1
#define JVM_F_OK 0
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void * JNICALL
JVM_GetThreadInterruptEvent();
/*
* These routines are only reentrant on Windows
*/
JNIEXPORT struct protoent * JNICALL
JVM_GetProtoByName(char* name);
JNIEXPORT struct hostent* JNICALL
JVM_GetHostByAddr(const char* name, int len, int type);
JNIEXPORT struct hostent* JNICALL
JVM_GetHostByName(char* name);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
/*
* File I/O
@ -89,19 +91,12 @@ JVM_GetHostByName(char* name);
#include <errno.h>
#include <signal.h>
/* O Flags */
#define JVM_O_RDONLY O_RDONLY
#define JVM_O_WRONLY O_WRONLY
#define JVM_O_RDWR O_RDWR
#define JVM_O_O_APPEND O_APPEND
#define JVM_O_EXCL O_EXCL
#define JVM_O_CREAT O_CREAT
/* Signals */
#define JVM_SIGINT SIGINT
#define JVM_SIGTERM SIGTERM
#define SHUTDOWN1_SIGNAL SIGINT /* Shutdown Hooks support. */
#define SHUTDOWN2_SIGNAL SIGTERM
#endif /* !_JAVASOFT_JVM_MD_H_ */