This commit is contained in:
Lana Steuck 2015-04-17 10:23:30 -07:00
commit 1c9cea3ec9
6 changed files with 116 additions and 30 deletions

View File

@ -30,6 +30,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.logging.Level;
@ -85,19 +87,25 @@ public final class ClassFactory {
if(consRef!=null)
cons = consRef.get();
if(cons==null) {
try {
cons = clazz.getDeclaredConstructor(emptyClass);
} catch (NoSuchMethodException e) {
logger.log(Level.INFO,"No default constructor found on "+clazz,e);
NoSuchMethodError exp;
if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS.format(clazz.getName()));
} else {
exp = new NoSuchMethodError(e.getMessage());
cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<T>>() {
@Override
public Constructor<T> run() {
try {
return clazz.getDeclaredConstructor(emptyClass);
} catch (NoSuchMethodException e) {
logger.log(Level.INFO,"No default constructor found on "+clazz,e);
NoSuchMethodError exp;
if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS
.format(clazz.getName()));
} else {
exp = new NoSuchMethodError(e.getMessage());
}
exp.initCause(e);
throw exp;
}
}
exp.initCause(e);
throw exp;
}
});
int classMod = clazz.getModifiers();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2015, 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
@ -108,7 +108,8 @@ public class Engine {
}
public Thread newThread(Runnable r) {
Thread t = new Thread(null, r, namePrefix + threadNumber.getAndIncrement(), 0);
Thread t = ThreadHelper.createNewThread(r);
t.setName(namePrefix + threadNumber.getAndIncrement());
if (!t.isDaemon()) {
t.setDaemon(true);
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 2015, 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 com.sun.xml.internal.ws.api.pipe;
import java.lang.reflect.Constructor;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* Simple utility class to instantiate correct Thread instance
* depending on runtime context (jdk/non-jdk usage)
*
* @author miroslav.kos@oracle.com
*/
final class ThreadHelper {
private static final String SAFE_THREAD_NAME = "sun.misc.ManagedLocalsThread";
private static final Constructor THREAD_CONSTRUCTOR;
// no instantiating wanted
private ThreadHelper() {
}
static {
THREAD_CONSTRUCTOR = AccessController.doPrivileged(
new PrivilegedAction<Constructor> () {
@Override
public Constructor run() {
try {
Class cls = Class.forName(SAFE_THREAD_NAME);
if (cls != null) {
return cls.getConstructor(Runnable.class);
}
} catch (ClassNotFoundException ignored) {
} catch (NoSuchMethodException ignored) {
}
return null;
}
}
);
}
static Thread createNewThread(final Runnable r) {
if (isJDKInternal()) {
return AccessController.doPrivileged(
new PrivilegedAction<Thread>() {
@Override
public Thread run() {
try {
return (Thread) THREAD_CONSTRUCTOR.newInstance(r);
} catch (Exception e) {
return new Thread(r);
}
}
}
);
} else {
return new Thread(r);
}
}
private static boolean isJDKInternal() {
String className = ThreadHelper.class.getName();
return className.contains(".internal.");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2015, 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
@ -894,15 +894,6 @@ public class WSServiceDelegate extends WSService {
return wsdlService;
}
static class DaemonThreadFactory implements ThreadFactory {
@Override
public Thread newThread(Runnable r) {
Thread daemonThread = new Thread(r);
daemonThread.setDaemon(Boolean.TRUE);
return daemonThread;
}
}
protected static final WebServiceFeature[] EMPTY_FEATURES = new WebServiceFeature[0];
private static ClassLoader getDelegatingLoader(ClassLoader loader1, ClassLoader loader2) {

View File

@ -36,9 +36,6 @@ import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
//TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver
import com.sun.xml.internal.bind.unmarshaller.DOMScanner;
//TODO MtomCodec
import com.sun.xml.internal.bind.v2.runtime.output.Encoded;
//TODO ExceptionBean
import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;

View File

@ -25,8 +25,6 @@
package com.sun.tools.internal.ws.wsdl.document.soap;
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
import javax.xml.namespace.QName;
/**
@ -37,7 +35,9 @@ import javax.xml.namespace.QName;
public interface SOAPConstants {
// namespace URIs
public static final String URI_ENVELOPE = SOAPNamespaceConstants.ENVELOPE;
public static final String URI_ENVELOPE =
"http://schemas.xmlsoap.org/soap/envelope/";
public static final String NS_WSDL_SOAP =
"http://schemas.xmlsoap.org/wsdl/soap/";
public static final String NS_SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/";