提交 0128b684 编写于 作者: M mfang

Merge

...@@ -289,3 +289,4 @@ bf4acb74e4a82d6126ad7a82bd8c52bdcce4bc8d jdk8u20-b14 ...@@ -289,3 +289,4 @@ bf4acb74e4a82d6126ad7a82bd8c52bdcce4bc8d jdk8u20-b14
d723d05cd17afd5c4dd4293bcba83fef44a3c0bb jdk8u20-b16 d723d05cd17afd5c4dd4293bcba83fef44a3c0bb jdk8u20-b16
31433e5da5bcfd107381f281058dc80377f04d23 jdk8u20-b17 31433e5da5bcfd107381f281058dc80377f04d23 jdk8u20-b17
266302e9c31172984493404d5b223979315b59ac jdk8u20-b18 266302e9c31172984493404d5b223979315b59ac jdk8u20-b18
38548d32c91cfa57b1d31eec0a5e79c936e86f11 jdk8u20-b19
...@@ -52,8 +52,9 @@ ifdef OPENJDK ...@@ -52,8 +52,9 @@ ifdef OPENJDK
endif endif
ifndef OPENJDK ifndef OPENJDK
# There exists two versions of this file... # There exists two versions of these files...
EXFILES := $(JDK_TOPDIR)/src/share/classes/javax/crypto/JarVerifier.java EXFILES := $(JDK_TOPDIR)/src/share/classes/javax/crypto/JarVerifier.java
EXFILES += $(JDK_TOPDIR)/src/share/classes/sun/management/ExtendedPlatformComponent.java
ifeq ($(OPENJDK_TARGET_OS), windows) ifeq ($(OPENJDK_TARGET_OS), windows)
# This gets built on unix platforms implicitly in the old build even though # This gets built on unix platforms implicitly in the old build even though
......
...@@ -52,6 +52,7 @@ import java.security.PrivilegedActionException; ...@@ -52,6 +52,7 @@ import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import javax.management.JMX; import javax.management.JMX;
import sun.management.ManagementFactoryHelper; import sun.management.ManagementFactoryHelper;
import sun.management.ExtendedPlatformComponent;
/** /**
* The {@code ManagementFactory} class is a factory class for getting * The {@code ManagementFactory} class is a factory class for getting
...@@ -489,6 +490,12 @@ public class ManagementFactory { ...@@ -489,6 +490,12 @@ public class ManagementFactory {
for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) { for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) {
addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey()); addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey());
} }
for (final PlatformManagedObject o :
ExtendedPlatformComponent.getMXBeans()) {
if (!platformMBeanServer.isRegistered(o.getObjectName())) {
addMXBean(platformMBeanServer, o);
}
}
} }
return platformMBeanServer; return platformMBeanServer;
} }
...@@ -655,9 +662,14 @@ public class ManagementFactory { ...@@ -655,9 +662,14 @@ public class ManagementFactory {
public static <T extends PlatformManagedObject> public static <T extends PlatformManagedObject>
T getPlatformMXBean(Class<T> mxbeanInterface) { T getPlatformMXBean(Class<T> mxbeanInterface) {
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null) if (pc == null) {
T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
if (mbean != null) {
return mbean;
}
throw new IllegalArgumentException(mxbeanInterface.getName() + throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface"); " is not a platform management interface");
}
if (!pc.isSingleton()) if (!pc.isSingleton())
throw new IllegalArgumentException(mxbeanInterface.getName() + throw new IllegalArgumentException(mxbeanInterface.getName() +
" can have zero or more than one instances"); " can have zero or more than one instances");
...@@ -690,9 +702,14 @@ public class ManagementFactory { ...@@ -690,9 +702,14 @@ public class ManagementFactory {
public static <T extends PlatformManagedObject> List<T> public static <T extends PlatformManagedObject> List<T>
getPlatformMXBeans(Class<T> mxbeanInterface) { getPlatformMXBeans(Class<T> mxbeanInterface) {
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null) if (pc == null) {
T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
if (mbean != null) {
return Collections.singletonList(mbean);
}
throw new IllegalArgumentException(mxbeanInterface.getName() + throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface"); " is not a platform management interface");
}
return Collections.unmodifiableList(pc.getMXBeans(mxbeanInterface)); return Collections.unmodifiableList(pc.getMXBeans(mxbeanInterface));
} }
...@@ -737,9 +754,17 @@ public class ManagementFactory { ...@@ -737,9 +754,17 @@ public class ManagementFactory {
throws java.io.IOException throws java.io.IOException
{ {
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null) if (pc == null) {
T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
if (mbean != null) {
ObjectName on = mbean.getObjectName();
return ManagementFactory.newPlatformMXBeanProxy(connection,
on.getCanonicalName(),
mxbeanInterface);
}
throw new IllegalArgumentException(mxbeanInterface.getName() + throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface"); " is not a platform management interface");
}
if (!pc.isSingleton()) if (!pc.isSingleton())
throw new IllegalArgumentException(mxbeanInterface.getName() + throw new IllegalArgumentException(mxbeanInterface.getName() +
" can have zero or more than one instances"); " can have zero or more than one instances");
...@@ -781,6 +806,13 @@ public class ManagementFactory { ...@@ -781,6 +806,13 @@ public class ManagementFactory {
{ {
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null) { if (pc == null) {
T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
if (mbean != null) {
ObjectName on = mbean.getObjectName();
T proxy = ManagementFactory.newPlatformMXBeanProxy(connection,
on.getCanonicalName(), mxbeanInterface);
return Collections.singletonList(proxy);
}
throw new IllegalArgumentException(mxbeanInterface.getName() + throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface"); " is not a platform management interface");
} }
......
...@@ -550,6 +550,7 @@ public class InsnList { ...@@ -550,6 +550,7 @@ public class InsnList {
} }
// this class is not generified because it will create bridges // this class is not generified because it will create bridges
@SuppressWarnings("rawtypes")
private final class InsnListIterator implements ListIterator { private final class InsnListIterator implements ListIterator {
AbstractInsnNode next; AbstractInsnNode next;
......
...@@ -399,6 +399,7 @@ public class MethodNode extends MethodVisitor { ...@@ -399,6 +399,7 @@ public class MethodNode extends MethodVisitor {
} }
@Override @Override
@SuppressWarnings("unchecked")
public AnnotationVisitor visitParameterAnnotation(final int parameter, public AnnotationVisitor visitParameterAnnotation(final int parameter,
final String desc, final boolean visible) { final String desc, final boolean visible) {
AnnotationNode an = new AnnotationNode(desc); AnnotationNode an = new AnnotationNode(desc);
......
...@@ -131,6 +131,7 @@ public class Analyzer<V extends Value> implements Opcodes { ...@@ -131,6 +131,7 @@ public class Analyzer<V extends Value> implements Opcodes {
* @throws AnalyzerException * @throws AnalyzerException
* if a problem occurs during the analysis. * if a problem occurs during the analysis.
*/ */
@SuppressWarnings("unchecked")
public Frame<V>[] analyze(final String owner, final MethodNode m) public Frame<V>[] analyze(final String owner, final MethodNode m)
throws AnalyzerException { throws AnalyzerException {
if ((m.access & (ACC_ABSTRACT | ACC_NATIVE)) != 0) { if ((m.access & (ACC_ABSTRACT | ACC_NATIVE)) != 0) {
......
...@@ -112,6 +112,7 @@ public class Frame<V extends Value> { ...@@ -112,6 +112,7 @@ public class Frame<V extends Value> {
* @param nStack * @param nStack
* the maximum stack size of the frame. * the maximum stack size of the frame.
*/ */
@SuppressWarnings("unchecked")
public Frame(final int nLocals, final int nStack) { public Frame(final int nLocals, final int nStack) {
this.values = (V[]) new Value[nLocals + nStack]; this.values = (V[]) new Value[nLocals + nStack];
this.locals = nLocals; this.locals = nLocals;
......
Path: . Path: .
Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-05-27 Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-06-19
URL: file:///svnroot/asm/trunk/asm URL: file:///svnroot/asm/trunk/asm
Repository Root: file:///svnroot/asm Repository Root: file:///svnroot/asm
Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9 Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9
Revision: 1748 Revision: 1750
Node Kind: directory Node Kind: directory
Schedule: normal Schedule: normal
Last Changed Author: ebruneton Last Changed Author: forax
Last Changed Rev: 1747 Last Changed Rev: 1750
Last Changed Date: 2014-05-24 10:22:13 +0200 (Sat, 24 May 2014) Last Changed Date: 2014-06-06 00:31:02 +0200 (Fri, 06 Jun 2014)
...@@ -119,6 +119,8 @@ public class Sockets { ...@@ -119,6 +119,8 @@ public class Sockets {
Throwable t = ((InvocationTargetException)e).getTargetException(); Throwable t = ((InvocationTargetException)e).getTargetException();
if (t instanceof IOException) { if (t instanceof IOException) {
throw (IOException)t; throw (IOException)t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException)t;
} }
} }
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -135,6 +137,8 @@ public class Sockets { ...@@ -135,6 +137,8 @@ public class Sockets {
Throwable t = ((InvocationTargetException)e).getTargetException(); Throwable t = ((InvocationTargetException)e).getTargetException();
if (t instanceof IOException) { if (t instanceof IOException) {
throw (IOException)t; throw (IOException)t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException)t;
} }
} }
throw new RuntimeException(e); throw new RuntimeException(e);
......
/* /*
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,8 +33,6 @@ import java.io.FileNotFoundException; ...@@ -33,8 +33,6 @@ import java.io.FileNotFoundException;
import java.util.*; import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import sun.reflect.misc.ReflectUtil;
/** /**
* @author Michael Martak * @author Michael Martak
* @since 1.4 * @since 1.4
...@@ -201,16 +199,19 @@ public abstract class ShellFolder extends File { ...@@ -201,16 +199,19 @@ public abstract class ShellFolder extends File {
// Static // Static
private static ShellFolderManager shellFolderManager; private static final ShellFolderManager shellFolderManager;
private static Invoker invoker; private static final Invoker invoker;
static { static {
String managerClassName = (String)Toolkit.getDefaultToolkit(). String managerClassName = (String)Toolkit.getDefaultToolkit().
getDesktopProperty("Shell.shellFolderManager"); getDesktopProperty("Shell.shellFolderManager");
Class managerClass = null; Class managerClass = null;
try { try {
managerClass = ReflectUtil.forName(managerClassName); managerClass = Class.forName(managerClassName, false, null);
if (!ShellFolderManager.class.isAssignableFrom(managerClass)) {
managerClass = null;
}
// swallow the exceptions below and use default shell folder // swallow the exceptions below and use default shell folder
} catch(ClassNotFoundException e) { } catch(ClassNotFoundException e) {
} catch(NullPointerException e) { } catch(NullPointerException e) {
......
/*
* Copyright (c) 2014, 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.
*/
package sun.management;
import java.util.Collections;
import java.util.List;
import java.lang.management.PlatformManagedObject;
/**
* Class to allow for an extended set of platform MXBeans
*/
public final class ExtendedPlatformComponent {
private ExtendedPlatformComponent() {} // Don't create any instances
/**
* Get the extended set of platform MXBeans that should be registered in the
* platform MBeanServer, or an empty list if there are no such MXBeans.
*/
public static List<? extends PlatformManagedObject> getMXBeans() {
return Collections.emptyList();
}
/**
* Returns the extended platform MXBean implementing the given
* mxbeanInterface, or null if there is no such MXBean.
*/
public static <T extends PlatformManagedObject>
T getMXBean(Class<T> mxbeanInterface) {
return null;
}
}
/* /*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -83,7 +83,7 @@ extern int wcanonicalizeWithPrefix(const WCHAR *canonicalPrefix, const WCHAR *pa ...@@ -83,7 +83,7 @@ extern int wcanonicalizeWithPrefix(const WCHAR *canonicalPrefix, const WCHAR *pa
* Retrieves the fully resolved (final) path for the given path or NULL * Retrieves the fully resolved (final) path for the given path or NULL
* if the function fails. * if the function fails.
*/ */
static WCHAR* getFinalPath(const WCHAR *path) static WCHAR* getFinalPath(JNIEnv *env, const WCHAR *path)
{ {
HANDLE h; HANDLE h;
WCHAR *result; WCHAR *result;
...@@ -119,6 +119,7 @@ static WCHAR* getFinalPath(const WCHAR *path) ...@@ -119,6 +119,7 @@ static WCHAR* getFinalPath(const WCHAR *path)
len = (*GetFinalPathNameByHandle_func)(h, result, len, 0); len = (*GetFinalPathNameByHandle_func)(h, result, len, 0);
} else { } else {
len = 0; len = 0;
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
} }
} }
...@@ -139,6 +140,7 @@ static WCHAR* getFinalPath(const WCHAR *path) ...@@ -139,6 +140,7 @@ static WCHAR* getFinalPath(const WCHAR *path)
/* copy result without prefix into new buffer */ /* copy result without prefix into new buffer */
WCHAR *tmp = (WCHAR*)malloc(resultLen * sizeof(WCHAR)); WCHAR *tmp = (WCHAR*)malloc(resultLen * sizeof(WCHAR));
if (tmp == NULL) { if (tmp == NULL) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
len = 0; len = 0;
} else { } else {
WCHAR *p = result; WCHAR *p = result;
...@@ -162,6 +164,8 @@ static WCHAR* getFinalPath(const WCHAR *path) ...@@ -162,6 +164,8 @@ static WCHAR* getFinalPath(const WCHAR *path)
free(result); free(result);
result = NULL; result = NULL;
} }
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
} }
error = GetLastError(); error = GetLastError();
...@@ -255,6 +259,8 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this, ...@@ -255,6 +259,8 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this,
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp)); rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
} }
free(cp); free(cp);
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
} }
} else } else
if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) { if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) {
...@@ -287,6 +293,8 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this, ...@@ -287,6 +293,8 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this,
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp)); rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
} }
free(cp); free(cp);
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
} }
} else } else
if (wcanonicalizeWithPrefix(canonicalPrefix, if (wcanonicalizeWithPrefix(canonicalPrefix,
...@@ -434,7 +442,7 @@ Java_java_io_WinNTFileSystem_setPermission(JNIEnv *env, jobject this, ...@@ -434,7 +442,7 @@ Java_java_io_WinNTFileSystem_setPermission(JNIEnv *env, jobject this,
if ((a != INVALID_FILE_ATTRIBUTES) && if ((a != INVALID_FILE_ATTRIBUTES) &&
((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0)) ((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
{ {
WCHAR *fp = getFinalPath(pathbuf); WCHAR *fp = getFinalPath(env, pathbuf);
if (fp == NULL) { if (fp == NULL) {
a = INVALID_FILE_ATTRIBUTES; a = INVALID_FILE_ATTRIBUTES;
} else { } else {
...@@ -624,6 +632,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) ...@@ -624,6 +632,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file)
if (search_path == 0) { if (search_path == 0) {
free (pathbuf); free (pathbuf);
errno = ENOMEM; errno = ENOMEM;
JNU_ThrowOutOfMemoryError(env, "native memory allocation faiuled");
return NULL; return NULL;
} }
wcscpy(search_path, pathbuf); wcscpy(search_path, pathbuf);
...@@ -801,7 +810,7 @@ Java_java_io_WinNTFileSystem_setReadOnly(JNIEnv *env, jobject this, ...@@ -801,7 +810,7 @@ Java_java_io_WinNTFileSystem_setReadOnly(JNIEnv *env, jobject this,
if ((a != INVALID_FILE_ATTRIBUTES) && if ((a != INVALID_FILE_ATTRIBUTES) &&
((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0)) ((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
{ {
WCHAR *fp = getFinalPath(pathbuf); WCHAR *fp = getFinalPath(env, pathbuf);
if (fp == NULL) { if (fp == NULL) {
a = INVALID_FILE_ATTRIBUTES; a = INVALID_FILE_ATTRIBUTES;
} else { } else {
......
/* /*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -191,9 +191,9 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -191,9 +191,9 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
int dirlen = currentDirLength(ps, pathlen); int dirlen = currentDirLength(ps, pathlen);
if (dirlen + pathlen + 1 > max_path - 1) { if (dirlen + pathlen + 1 > max_path - 1) {
pathbuf = prefixAbpath(ps, pathlen, dirlen + pathlen); pathbuf = prefixAbpath(ps, pathlen, dirlen + pathlen);
if( pathbuf == NULL) { if (pathbuf == NULL) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL; return NULL;
} }
} else { } else {
pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR)); pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
...@@ -216,12 +216,17 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -216,12 +216,17 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
return NULL; return NULL;
} else { } else {
pathbuf = (WCHAR*)malloc(sizeof(WCHAR)); pathbuf = (WCHAR*)malloc(sizeof(WCHAR));
pathbuf[0] = L'\0'; if (pathbuf != NULL) {
pathbuf[0] = L'\0';
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
}
} }
} }
if (pathbuf == 0) { if (pathbuf == 0) {
if (!(*env)->ExceptionCheck(env)) { if (!(*env)->ExceptionCheck(env)) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
} }
return NULL; return NULL;
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2014 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -32,10 +32,17 @@ static jstring ...@@ -32,10 +32,17 @@ static jstring
environmentBlock9x(JNIEnv *env) environmentBlock9x(JNIEnv *env)
{ {
int i; int i;
jmethodID String_init_ID = jmethodID String_init_ID;
(*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
jbyteArray bytes; jbyteArray bytes;
jbyte *blockA = (jbyte *) GetEnvironmentStringsA(); jbyte *blockA;
jclass string_class;
string_class= JNU_ClassString(env);
CHECK_NULL_RETURN(string_class, NULL);
String_init_ID =
(*env)->GetMethodID(env, string_class, "<init>", "([B)V");
CHECK_NULL_RETURN(String_init_ID, NULL);
blockA = (jbyte *) GetEnvironmentStringsA();
if (blockA == NULL) { if (blockA == NULL) {
/* Both GetEnvironmentStringsW and GetEnvironmentStringsA /* Both GetEnvironmentStringsW and GetEnvironmentStringsA
* failed. Out of memory is our best guess. */ * failed. Out of memory is our best guess. */
...@@ -49,10 +56,13 @@ environmentBlock9x(JNIEnv *env) ...@@ -49,10 +56,13 @@ environmentBlock9x(JNIEnv *env)
while (blockA[i++]) while (blockA[i++])
; ;
if ((bytes = (*env)->NewByteArray(env, i)) == NULL) return NULL; if ((bytes = (*env)->NewByteArray(env, i)) == NULL) {
FreeEnvironmentStringsA(blockA);
return NULL;
}
(*env)->SetByteArrayRegion(env, bytes, 0, i, blockA); (*env)->SetByteArrayRegion(env, bytes, 0, i, blockA);
FreeEnvironmentStringsA(blockA); FreeEnvironmentStringsA(blockA);
return (*env)->NewObject(env, JNU_ClassString(env), return (*env)->NewObject(env, string_class,
String_init_ID, bytes); String_init_ID, bytes);
} }
......
...@@ -359,24 +359,28 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored, ...@@ -359,24 +359,28 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored,
const jchar *penvBlock = (envBlock != NULL) const jchar *penvBlock = (envBlock != NULL)
? (*env)->GetStringChars(env, envBlock, NULL) ? (*env)->GetStringChars(env, envBlock, NULL)
: NULL; : NULL;
const jchar *pdir = (dir != NULL) if (!(*env)->ExceptionCheck(env)) {
? (*env)->GetStringChars(env, dir, NULL) const jchar *pdir = (dir != NULL)
: NULL; ? (*env)->GetStringChars(env, dir, NULL)
jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL); : NULL;
if (handles != NULL) { if (!(*env)->ExceptionCheck(env)) {
ret = processCreate( jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL);
env, if (handles != NULL) {
pcmd, ret = processCreate(
penvBlock, env,
pdir, pcmd,
handles, penvBlock,
redirectErrorStream); pdir,
(*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0); handles,
redirectErrorStream);
(*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0);
}
if (pdir != NULL)
(*env)->ReleaseStringChars(env, dir, pdir);
}
if (penvBlock != NULL)
(*env)->ReleaseStringChars(env, envBlock, penvBlock);
} }
if (pdir != NULL)
(*env)->ReleaseStringChars(env, dir, pdir);
if (penvBlock != NULL)
(*env)->ReleaseStringChars(env, envBlock, penvBlock);
(*env)->ReleaseStringChars(env, cmd, pcmd); (*env)->ReleaseStringChars(env, cmd, pcmd);
} }
} }
...@@ -448,7 +452,7 @@ Java_java_lang_ProcessImpl_isProcessAlive(JNIEnv *env, jclass ignored, jlong han ...@@ -448,7 +452,7 @@ Java_java_lang_ProcessImpl_isProcessAlive(JNIEnv *env, jclass ignored, jlong han
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_java_lang_ProcessImpl_closeHandle(JNIEnv *env, jclass ignored, jlong handle) Java_java_lang_ProcessImpl_closeHandle(JNIEnv *env, jclass ignored, jlong handle)
{ {
return CloseHandle((HANDLE) handle); return (jboolean) CloseHandle((HANDLE) handle);
} }
/** /**
......
/* /*
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <jni.h>
#include <windows.h> #include <windows.h>
#include "jni.h"
#include "jni_util.h"
#include "jvm.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -37,12 +39,15 @@ extern "C" { ...@@ -37,12 +39,15 @@ extern "C" {
int errorCode=-1; int errorCode=-1;
jintArray result; jintArray result;
str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
CHECK_NULL_RETURN(str, NULL);
errorCode = RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle); errorCode = RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
(*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
tmp[0]= (int) handle; tmp[0]= (int) handle;
tmp[1]= errorCode; tmp[1]= errorCode;
result = (*env)->NewIntArray(env,2); result = (*env)->NewIntArray(env,2);
(*env)->SetIntArrayRegion(env, result, 0, 2, tmp); if (result != NULL) {
(*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
}
return result; return result;
} }
...@@ -58,8 +63,9 @@ extern "C" { ...@@ -58,8 +63,9 @@ extern "C" {
int tmp[3]; int tmp[3];
DWORD lpdwDisposition; DWORD lpdwDisposition;
int errorCode; int errorCode;
jintArray result; jintArray result = NULL;
str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
CHECK_NULL_RETURN(str, NULL);
errorCode = RegCreateKeyEx((HKEY)hKey, str, 0, NULL, errorCode = RegCreateKeyEx((HKEY)hKey, str, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_READ, REG_OPTION_NON_VOLATILE, KEY_READ,
NULL, &handle, &lpdwDisposition); NULL, &handle, &lpdwDisposition);
...@@ -68,7 +74,9 @@ extern "C" { ...@@ -68,7 +74,9 @@ extern "C" {
tmp[1]= errorCode; tmp[1]= errorCode;
tmp[2]= lpdwDisposition; tmp[2]= lpdwDisposition;
result = (*env)->NewIntArray(env,3); result = (*env)->NewIntArray(env,3);
(*env)->SetIntArrayRegion(env, result, 0, 3, tmp); if (result != NULL) {
(*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
}
return result; return result;
} }
...@@ -77,6 +85,7 @@ extern "C" { ...@@ -77,6 +85,7 @@ extern "C" {
char* str; char* str;
int result; int result;
str = (*env)->GetByteArrayElements(env, lpSubKey, NULL); str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
CHECK_NULL_RETURN(str, -1);
result = RegDeleteKey((HKEY)hKey, str); result = RegDeleteKey((HKEY)hKey, str);
(*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
return result; return result;
...@@ -96,6 +105,7 @@ extern "C" { ...@@ -96,6 +105,7 @@ extern "C" {
DWORD valueType; DWORD valueType;
DWORD valueSize; DWORD valueSize;
valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
CHECK_NULL_RETURN(valueNameStr, NULL);
if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL, if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL,
&valueSize) != ERROR_SUCCESS) { &valueSize) != ERROR_SUCCESS) {
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
...@@ -104,18 +114,26 @@ extern "C" { ...@@ -104,18 +114,26 @@ extern "C" {
buffer = (char*)malloc(valueSize); buffer = (char*)malloc(valueSize);
if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer, if (buffer != NULL) {
&valueSize) != ERROR_SUCCESS) { if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
free(buffer); &valueSize) != ERROR_SUCCESS) {
free(buffer);
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
return NULL;
}
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
return NULL; return NULL;
} }
if (valueType == REG_SZ) { if (valueType == REG_SZ) {
result = (*env)->NewByteArray(env, valueSize); result = (*env)->NewByteArray(env, valueSize);
(*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer); if (result != NULL) {
(*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
}
} else { } else {
result = NULL; result = NULL;
} }
free(buffer); free(buffer);
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
...@@ -135,7 +153,9 @@ extern "C" { ...@@ -135,7 +153,9 @@ extern "C" {
if ((valueName == NULL)||(data == NULL)) {return -1;} if ((valueName == NULL)||(data == NULL)) {return -1;}
size = (*env)->GetArrayLength(env, data); size = (*env)->GetArrayLength(env, data);
dataStr = (*env)->GetByteArrayElements(env, data, NULL); dataStr = (*env)->GetByteArrayElements(env, data, NULL);
CHECK_NULL_RETURN(dataStr, -1);
valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
CHECK_NULL_RETURN(valueNameStr, -1);
error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0, error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
REG_SZ, dataStr, size); REG_SZ, dataStr, size);
(*env)->ReleaseByteArrayElements(env, data, dataStr, 0); (*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
...@@ -149,6 +169,7 @@ extern "C" { ...@@ -149,6 +169,7 @@ extern "C" {
int error_code = -1; int error_code = -1;
if (valueName == NULL) {return -1;} if (valueName == NULL) {return -1;}
valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL); valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
CHECK_NULL_RETURN(valueNameStr, -1);
error_code = RegDeleteValue((HKEY)hKey, valueNameStr); error_code = RegDeleteValue((HKEY)hKey, valueNameStr);
(*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0); (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
return error_code; return error_code;
...@@ -156,7 +177,7 @@ extern "C" { ...@@ -156,7 +177,7 @@ extern "C" {
JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
(JNIEnv* env, jclass this_class, jint hKey) { (JNIEnv* env, jclass this_class, jint hKey) {
jintArray result; jintArray result = NULL;
int tmp[5]; int tmp[5];
int valuesNumber = -1; int valuesNumber = -1;
int maxValueNameLength = -1; int maxValueNameLength = -1;
...@@ -173,7 +194,9 @@ extern "C" { ...@@ -173,7 +194,9 @@ extern "C" {
tmp[3]= maxSubKeyLength; tmp[3]= maxSubKeyLength;
tmp[4]= maxValueNameLength; tmp[4]= maxValueNameLength;
result = (*env)->NewIntArray(env,5); result = (*env)->NewIntArray(env,5);
(*env)->SetIntArrayRegion(env, result, 0, 5, tmp); if (result != NULL) {
(*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
}
return result; return result;
} }
...@@ -183,13 +206,19 @@ extern "C" { ...@@ -183,13 +206,19 @@ extern "C" {
jbyteArray result; jbyteArray result;
char* buffer = NULL; char* buffer = NULL;
buffer = (char*)malloc(maxKeyLength); buffer = (char*)malloc(maxKeyLength);
if (buffer == NULL) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
}
if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL, if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL,
NULL, NULL) != ERROR_SUCCESS){ NULL, NULL) != ERROR_SUCCESS){
free(buffer); free(buffer);
return NULL; return NULL;
} }
result = (*env)->NewByteArray(env, size + 1); result = (*env)->NewByteArray(env, size + 1);
(*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer); if (result != NULL) {
(*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
}
free(buffer); free(buffer);
return result; return result;
} }
...@@ -201,6 +230,10 @@ extern "C" { ...@@ -201,6 +230,10 @@ extern "C" {
char* buffer = NULL; char* buffer = NULL;
int error_code; int error_code;
buffer = (char*)malloc(maxValueNameLength); buffer = (char*)malloc(maxValueNameLength);
if (buffer == NULL) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
}
error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer, error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
&size, NULL, NULL, NULL, NULL); &size, NULL, NULL, NULL, NULL);
if (error_code!= ERROR_SUCCESS){ if (error_code!= ERROR_SUCCESS){
...@@ -208,7 +241,9 @@ extern "C" { ...@@ -208,7 +241,9 @@ extern "C" {
return NULL; return NULL;
} }
result = (*env)->NewByteArray(env, size + 1); result = (*env)->NewByteArray(env, size + 1);
(*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer); if (result != NULL) {
(*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
}
free(buffer); free(buffer);
return result; return result;
} }
......
...@@ -53,7 +53,9 @@ JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_init ...@@ -53,7 +53,9 @@ JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_init
(JNIEnv *env, jclass authseq_clazz, jclass status_clazz) (JNIEnv *env, jclass authseq_clazz, jclass status_clazz)
{ {
ntlm_ctxHandleID = (*env)->GetFieldID(env, authseq_clazz, "ctxHandle", "J"); ntlm_ctxHandleID = (*env)->GetFieldID(env, authseq_clazz, "ctxHandle", "J");
CHECK_NULL(ntlm_ctxHandleID);
ntlm_crdHandleID = (*env)->GetFieldID(env, authseq_clazz, "crdHandle", "J"); ntlm_crdHandleID = (*env)->GetFieldID(env, authseq_clazz, "crdHandle", "J");
CHECK_NULL(ntlm_crdHandleID);
status_seqCompleteID = (*env)->GetFieldID(env, status_clazz, "sequenceComplete", "Z"); status_seqCompleteID = (*env)->GetFieldID(env, status_clazz, "sequenceComplete", "Z");
} }
...@@ -100,6 +102,16 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_get ...@@ -100,6 +102,16 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_get
} }
} }
pCred = (CredHandle *)malloc(sizeof (CredHandle)); pCred = (CredHandle *)malloc(sizeof (CredHandle));
if (pCred == NULL) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
if (pUser != NULL)
JNU_ReleaseStringPlatformChars(env, user, pUser);
if (pPassword != NULL)
JNU_ReleaseStringPlatformChars(env, password, pPassword);
if (pDomain != NULL)
JNU_ReleaseStringPlatformChars(env, domain, pDomain);
return NULL;
}
if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) { if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) {
pAuthId = &AuthId; pAuthId = &AuthId;
...@@ -177,7 +189,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc ...@@ -177,7 +189,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID); pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID);
if (pCtx == 0) { /* first call */ if (pCtx == 0) { /* first call */
newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle)); newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle));
(*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext); if (newContext != NULL) {
(*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
}
} else { } else {
newContext = pCtx; newContext = pCtx;
} }
...@@ -198,6 +215,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc ...@@ -198,6 +215,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
if (lastToken != 0) if (lastToken != 0)
{ {
pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy); pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy);
CHECK_NULL_RETURN(pInput, NULL);
inputLen = (*env)->GetArrayLength(env, lastToken); inputLen = (*env)->GetArrayLength(env, lastToken);
InBuffDesc.ulVersion = 0; InBuffDesc.ulVersion = 0;
...@@ -240,8 +258,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc ...@@ -240,8 +258,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
if ( OutSecBuff.cbBuffer > 0 ) { if ( OutSecBuff.cbBuffer > 0 ) {
jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer); jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer);
(*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer, if (ret != NULL) {
OutSecBuff.pvBuffer); (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
OutSecBuff.pvBuffer);
}
if (lastToken != 0) // 2nd stage if (lastToken != 0) // 2nd stage
endSequence (pCred, pCtx, env, status); endSequence (pCred, pCtx, env, status);
result = ret; result = ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册