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

Merge

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