Merge
This commit is contained in:
commit
023b8f4338
@ -363,3 +363,4 @@ baeb5edb38939cdb78ae0ac6f4fd368465cbf188 jdk-9+116
|
|||||||
e1eba5cfa5cc8c66d524396a05323dc93568730a jdk-9+118
|
e1eba5cfa5cc8c66d524396a05323dc93568730a jdk-9+118
|
||||||
bad3f8a33db271a6143ba6eac0c8bd5bbd942417 jdk-9+119
|
bad3f8a33db271a6143ba6eac0c8bd5bbd942417 jdk-9+119
|
||||||
b9a518bf72516954e57ac2f6e3ef21e13008f1cd jdk-9+120
|
b9a518bf72516954e57ac2f6e3ef21e13008f1cd jdk-9+120
|
||||||
|
ee29aaab5889555ea56e4c0ed690aabb7613529d jdk-9+121
|
||||||
|
@ -212,9 +212,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBZIP, \
|
|||||||
-I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
|
-I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
|
||||||
-I$(SUPPORT_OUTPUTDIR)/headers/java.base, \
|
-I$(SUPPORT_OUTPUTDIR)/headers/java.base, \
|
||||||
CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
|
CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
|
||||||
DISABLED_WARNINGS_gcc := parentheses, \
|
|
||||||
DISABLED_WARNINGS_clang := dangling-else, \
|
|
||||||
DISABLED_WARNINGS_microsoft := 4267, \
|
|
||||||
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libzip/mapfile-vers, \
|
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libzip/mapfile-vers, \
|
||||||
REORDER := $(BUILD_LIBZIP_REORDER), \
|
REORDER := $(BUILD_LIBZIP_REORDER), \
|
||||||
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -29,8 +29,6 @@ import jdk.internal.misc.SharedSecrets;
|
|||||||
|
|
||||||
import static java.lang.StackWalker.Option.*;
|
import static java.lang.StackWalker.Option.*;
|
||||||
import java.lang.StackWalker.StackFrame;
|
import java.lang.StackWalker.StackFrame;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
class StackFrameInfo implements StackFrame {
|
class StackFrameInfo implements StackFrame {
|
||||||
private final static JavaLangInvokeAccess JLIA =
|
private final static JavaLangInvokeAccess JLIA =
|
||||||
@ -82,19 +80,21 @@ class StackFrameInfo implements StackFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getByteCodeIndex() {
|
public int getByteCodeIndex() {
|
||||||
|
// bci not available for native methods
|
||||||
|
if (isNativeMethod())
|
||||||
|
return -1;
|
||||||
|
|
||||||
return bci;
|
return bci;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
if (isNativeMethod())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return toStackTraceElement().getFileName();
|
return toStackTraceElement().getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLineNumber() {
|
public int getLineNumber() {
|
||||||
|
// line number not available for native methods
|
||||||
if (isNativeMethod())
|
if (isNativeMethod())
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -680,7 +680,8 @@ final class StackStreamFactory {
|
|||||||
// 1: caller-sensitive method
|
// 1: caller-sensitive method
|
||||||
// 2: caller class
|
// 2: caller class
|
||||||
while (n < 2 && (caller = nextFrame()) != null) {
|
while (n < 2 && (caller = nextFrame()) != null) {
|
||||||
if (isMethodHandleFrame(caller)) continue;
|
if (isMethodHandleFrame(caller)) { continue; }
|
||||||
|
if (isReflectionFrame(caller)) { continue; }
|
||||||
frames[n++] = caller;
|
frames[n++] = caller;
|
||||||
}
|
}
|
||||||
if (frames[1] == null) {
|
if (frames[1] == null) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -468,23 +468,23 @@ public final class StackWalker {
|
|||||||
* Gets the {@code Class} object of the caller invoking the method
|
* Gets the {@code Class} object of the caller invoking the method
|
||||||
* that calls this {@code getCallerClass} method.
|
* that calls this {@code getCallerClass} method.
|
||||||
*
|
*
|
||||||
* <p> Reflection frames, {@link java.lang.invoke.MethodHandle} and
|
* <p> Reflection frames, {@link java.lang.invoke.MethodHandle}, and
|
||||||
* hidden frames are filtered regardless of the
|
* hidden frames are filtered regardless of the
|
||||||
* {@link Option#SHOW_REFLECT_FRAMES SHOW_REFLECT_FRAMES}
|
* {@link Option#SHOW_REFLECT_FRAMES SHOW_REFLECT_FRAMES}
|
||||||
* and {@link Option#SHOW_HIDDEN_FRAMES SHOW_HIDDEN_FRAMES} options
|
* and {@link Option#SHOW_HIDDEN_FRAMES SHOW_HIDDEN_FRAMES} options
|
||||||
* this {@code StackWalker} has been configured.
|
* this {@code StackWalker} has been configured with.
|
||||||
*
|
*
|
||||||
* <p> This method throws {@code UnsupportedOperationException}
|
* <p> This method throws {@code UnsupportedOperationException}
|
||||||
* if this {@code StackWalker} is not configured with
|
* if this {@code StackWalker} is not configured with the
|
||||||
* {@link Option#RETAIN_CLASS_REFERENCE RETAIN_CLASS_REFERENCE} option,
|
* {@link Option#RETAIN_CLASS_REFERENCE RETAIN_CLASS_REFERENCE} option.
|
||||||
* This method should be called when a caller frame is present. If
|
* This method should be called when a caller frame is present. If
|
||||||
* it is called from the last frame on the stack;
|
* it is called from the last frame on the stack,
|
||||||
* {@code IllegalStateException} will be thrown.
|
* {@code IllegalStateException} will be thrown.
|
||||||
*
|
*
|
||||||
* @apiNote
|
* @apiNote
|
||||||
* For example, {@code Util::getResourceBundle} loads a resource bundle
|
* For example, {@code Util::getResourceBundle} loads a resource bundle
|
||||||
* on behalf of the caller. It calls this {@code getCallerClass} method
|
* on behalf of the caller. It calls this {@code getCallerClass} method
|
||||||
* to find the method calling {@code Util::getResourceBundle} and use the caller's
|
* to find the method calling {@code Util::getResourceBundle} and uses the caller's
|
||||||
* class loader to load the resource bundle. The caller class in this example
|
* class loader to load the resource bundle. The caller class in this example
|
||||||
* is the {@code MyTool} class.
|
* is the {@code MyTool} class.
|
||||||
*
|
*
|
||||||
@ -519,7 +519,7 @@ public final class StackWalker {
|
|||||||
* When the {@code getCallerClass} method is called from a method that
|
* When the {@code getCallerClass} method is called from a method that
|
||||||
* is the last frame on the stack,
|
* is the last frame on the stack,
|
||||||
* for example, {@code static public void main} method launched by the
|
* for example, {@code static public void main} method launched by the
|
||||||
* {@code java} launcher or a method invoked from a JNI attached thread.
|
* {@code java} launcher, or a method invoked from a JNI attached thread,
|
||||||
* {@code IllegalStateException} is thrown.
|
* {@code IllegalStateException} is thrown.
|
||||||
*
|
*
|
||||||
* @return {@code Class} object of the caller's caller invoking this method.
|
* @return {@code Class} object of the caller's caller invoking this method.
|
||||||
|
@ -3360,9 +3360,9 @@ assertEquals("xy", h3.invoke("x", "y", 1, "a", "b", "c"));
|
|||||||
* @param pos place in {@code newTypes} where the non-skipped target parameters must occur
|
* @param pos place in {@code newTypes} where the non-skipped target parameters must occur
|
||||||
* @return a possibly adapted method handle
|
* @return a possibly adapted method handle
|
||||||
* @throws NullPointerException if either argument is null
|
* @throws NullPointerException if either argument is null
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException if any element of {@code newTypes} is {@code void.class},
|
||||||
* if either index is out of range in its corresponding list, or
|
* or if either index is out of range in its corresponding list,
|
||||||
* if the non-skipped target parameter types match the new types at {@code pos}
|
* or if the non-skipped target parameter types match the new types at {@code pos}
|
||||||
* @since 9
|
* @since 9
|
||||||
*/
|
*/
|
||||||
public static
|
public static
|
||||||
|
@ -3194,6 +3194,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
flags &= ~(UNICODE_CHARACTER_CLASS | UNICODE_CASE);
|
flags &= ~(UNICODE_CHARACTER_CLASS | UNICODE_CASE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,36 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
|||||||
* {@code AbstractResourceBundleProvider} is an abstract class for helping
|
* {@code AbstractResourceBundleProvider} is an abstract class for helping
|
||||||
* implement the {@link ResourceBundleProvider} interface.
|
* implement the {@link ResourceBundleProvider} interface.
|
||||||
*
|
*
|
||||||
|
* <p>
|
||||||
|
* Resource bundles can be packaged in a named module separated from
|
||||||
|
* the <em>caller module</em> loading the resource bundle, i.e. the module
|
||||||
|
* calling {@link ResourceBundle#getBundle(String)}. For the caller module
|
||||||
|
* to load a resource bundle "{@code com.example.app.MyResources}"
|
||||||
|
* from another module and a service interface named
|
||||||
|
* "{@code com.example.app.MyResourcesProvider}",
|
||||||
|
* the <em>bundle provider module</em> can provide the implementation class
|
||||||
|
* as follows:
|
||||||
|
*
|
||||||
|
* <pre><code>
|
||||||
|
* import com.example.app.MyResourcesProvider;
|
||||||
|
* class MyResourcesProviderImpl extends AbstractResourceBundleProvider
|
||||||
|
* implements MyResourcesProvider
|
||||||
|
* {</code>
|
||||||
|
* {@code @Override
|
||||||
|
* public ResourceBundle getBundle(String baseName, Locale locale) {
|
||||||
|
* // this module only provides bundles in french
|
||||||
|
* if (locale.equals(Locale.FRENCH)) {
|
||||||
|
* return super.getBundle(baseName, locale);
|
||||||
|
* }
|
||||||
|
* return null;
|
||||||
|
* }
|
||||||
|
* }}</pre>
|
||||||
|
*
|
||||||
|
* @see <a href="../ResourceBundle.html#bundleprovider">
|
||||||
|
* Resource Bundles in Named Modules</a>
|
||||||
|
* @see <a href="../ResourceBundle.html#RBP_support">
|
||||||
|
* ResourceBundleProvider Service Providers</a>
|
||||||
|
*
|
||||||
* @since 9
|
* @since 9
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractResourceBundleProvider implements ResourceBundleProvider {
|
public abstract class AbstractResourceBundleProvider implements ResourceBundleProvider {
|
||||||
@ -125,6 +155,7 @@ public abstract class AbstractResourceBundleProvider implements ResourceBundlePr
|
|||||||
Module module = this.getClass().getModule();
|
Module module = this.getClass().getModule();
|
||||||
String bundleName = toBundleName(baseName, locale);
|
String bundleName = toBundleName(baseName, locale);
|
||||||
ResourceBundle bundle = null;
|
ResourceBundle bundle = null;
|
||||||
|
|
||||||
for (String format : formats) {
|
for (String format : formats) {
|
||||||
try {
|
try {
|
||||||
if (FORMAT_CLASS.equals(format)) {
|
if (FORMAT_CLASS.equals(format)) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -30,13 +30,21 @@ import java.util.ResourceBundle;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code ResourceBundleProvider} is a provider interface that is used for
|
* {@code ResourceBundleProvider} is a provider interface that is used for
|
||||||
* loading resource bundles. Implementation classes of this interface are loaded
|
* loading resource bundles for named modules. Implementation classes of
|
||||||
* with {@link java.util.ServiceLoader ServiceLoader} during a call to the
|
* this interface are loaded with {@link java.util.ServiceLoader ServiceLoader}
|
||||||
|
* during a call to the
|
||||||
* {@link ResourceBundle#getBundle(String, Locale, ClassLoader)
|
* {@link ResourceBundle#getBundle(String, Locale, ClassLoader)
|
||||||
* ResourceBundle.getBundle} method. The provider service type is determined by
|
* ResourceBundle.getBundle} method. The provider service type is determined by
|
||||||
* {@code basename+"Provider"}. For example, if the base name is
|
* {@code basename+"Provider"}.
|
||||||
* "com.example.app.MyResources", {@code com.example.app.MyResourcesProvider}
|
*
|
||||||
* will be the provider service type.
|
* <p>
|
||||||
|
* For example, if the base name is "com.example.app.MyResources",
|
||||||
|
* {@code com.example.app.MyResourcesProvider} will be the provider service type:
|
||||||
|
* <pre>{@code
|
||||||
|
* public interface MyResourcesProvider extends ResourceBundleProvider {
|
||||||
|
* }
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This providers's {@link #getBundle(String, Locale) getBundle} method is called
|
* This providers's {@link #getBundle(String, Locale) getBundle} method is called
|
||||||
* through the resource bundle loading process instead of {@link
|
* through the resource bundle loading process instead of {@link
|
||||||
@ -44,13 +52,17 @@ import java.util.ResourceBundle;
|
|||||||
* ResourceBundle.Control.newBundle()}. Refer to {@link ResourceBundle} for
|
* ResourceBundle.Control.newBundle()}. Refer to {@link ResourceBundle} for
|
||||||
* details.
|
* details.
|
||||||
*
|
*
|
||||||
|
* @see <a href="../ResourceBundle.html#bundleprovider">
|
||||||
|
* Resource Bundles in Named Modules</a>
|
||||||
|
* @see <a href="../ResourceBundle.html#RBP_support">
|
||||||
|
* ResourceBundleProvider Service Providers</a>
|
||||||
* @since 9
|
* @since 9
|
||||||
*/
|
*/
|
||||||
public interface ResourceBundleProvider {
|
public interface ResourceBundleProvider {
|
||||||
/**
|
/**
|
||||||
* Returns a {@code ResourceBundle} for the given bundle name and locale.
|
* Returns a {@code ResourceBundle} for the given bundle name and locale.
|
||||||
* This method returns null if there is no {@code ResourceBundle} found
|
* This method returns {@code null} if there is no {@code ResourceBundle}
|
||||||
* for the given parameters.
|
* found for the given parameters.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param baseName
|
* @param baseName
|
||||||
|
@ -582,16 +582,17 @@ readCEN(jzfile *zip, jint knownTotal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cenlen > endpos)
|
if (cenlen > endpos) {
|
||||||
ZIP_FORMAT_ERROR("invalid END header (bad central directory size)");
|
ZIP_FORMAT_ERROR("invalid END header (bad central directory size)");
|
||||||
|
}
|
||||||
cenpos = endpos - cenlen;
|
cenpos = endpos - cenlen;
|
||||||
|
|
||||||
/* Get position of first local file (LOC) header, taking into
|
/* Get position of first local file (LOC) header, taking into
|
||||||
* account that there may be a stub prefixed to the zip file. */
|
* account that there may be a stub prefixed to the zip file. */
|
||||||
zip->locpos = cenpos - cenoff;
|
zip->locpos = cenpos - cenoff;
|
||||||
if (zip->locpos < 0)
|
if (zip->locpos < 0) {
|
||||||
ZIP_FORMAT_ERROR("invalid END header (bad central directory offset)");
|
ZIP_FORMAT_ERROR("invalid END header (bad central directory offset)");
|
||||||
|
}
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
if (zip->usemmap) {
|
if (zip->usemmap) {
|
||||||
/* On Solaris & Linux prior to JDK 6, we used to mmap the whole jar file to
|
/* On Solaris & Linux prior to JDK 6, we used to mmap the whole jar file to
|
||||||
@ -681,15 +682,18 @@ readCEN(jzfile *zip, jint knownTotal)
|
|||||||
method = CENHOW(cp);
|
method = CENHOW(cp);
|
||||||
nlen = CENNAM(cp);
|
nlen = CENNAM(cp);
|
||||||
|
|
||||||
if (!CENSIG_AT(cp))
|
if (!CENSIG_AT(cp)) {
|
||||||
ZIP_FORMAT_ERROR("invalid CEN header (bad signature)");
|
ZIP_FORMAT_ERROR("invalid CEN header (bad signature)");
|
||||||
if (CENFLG(cp) & 1)
|
}
|
||||||
|
if (CENFLG(cp) & 1) {
|
||||||
ZIP_FORMAT_ERROR("invalid CEN header (encrypted entry)");
|
ZIP_FORMAT_ERROR("invalid CEN header (encrypted entry)");
|
||||||
if (method != STORED && method != DEFLATED)
|
}
|
||||||
|
if (method != STORED && method != DEFLATED) {
|
||||||
ZIP_FORMAT_ERROR("invalid CEN header (bad compression method)");
|
ZIP_FORMAT_ERROR("invalid CEN header (bad compression method)");
|
||||||
if (cp + CENHDR + nlen > cenend)
|
}
|
||||||
|
if (cp + CENHDR + nlen > cenend) {
|
||||||
ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
|
ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
|
||||||
|
}
|
||||||
/* if the entry is metadata add it to our metadata names */
|
/* if the entry is metadata add it to our metadata names */
|
||||||
if (isMetaName((char *)cp+CENHDR, nlen))
|
if (isMetaName((char *)cp+CENHDR, nlen))
|
||||||
if (addMetaName(zip, (char *)cp+CENHDR, nlen) != 0)
|
if (addMetaName(zip, (char *)cp+CENHDR, nlen) != 0)
|
||||||
@ -704,9 +708,9 @@ readCEN(jzfile *zip, jint knownTotal)
|
|||||||
entries[i].next = table[hsh];
|
entries[i].next = table[hsh];
|
||||||
table[hsh] = i;
|
table[hsh] = i;
|
||||||
}
|
}
|
||||||
if (cp != cenend)
|
if (cp != cenend) {
|
||||||
ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
|
ZIP_FORMAT_ERROR("invalid CEN header (bad header size)");
|
||||||
|
}
|
||||||
zip->total = i;
|
zip->total = i;
|
||||||
goto Finally;
|
goto Finally;
|
||||||
|
|
||||||
@ -1115,7 +1119,7 @@ jzentry *
|
|||||||
ZIP_GetEntry(jzfile *zip, char *name, jint ulen)
|
ZIP_GetEntry(jzfile *zip, char *name, jint ulen)
|
||||||
{
|
{
|
||||||
if (ulen == 0) {
|
if (ulen == 0) {
|
||||||
return ZIP_GetEntry2(zip, name, strlen(name), JNI_FALSE);
|
return ZIP_GetEntry2(zip, name, (jint)strlen(name), JNI_FALSE);
|
||||||
}
|
}
|
||||||
return ZIP_GetEntry2(zip, name, ulen, JNI_TRUE);
|
return ZIP_GetEntry2(zip, name, ulen, JNI_TRUE);
|
||||||
}
|
}
|
||||||
@ -1441,7 +1445,7 @@ ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP)
|
|||||||
jzentry *entry = ZIP_GetEntry(zip, name, 0);
|
jzentry *entry = ZIP_GetEntry(zip, name, 0);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
*sizeP = (jint)entry->size;
|
*sizeP = (jint)entry->size;
|
||||||
*nameLenP = strlen(entry->name);
|
*nameLenP = (jint)strlen(entry->name);
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ class Http2Connection implements BufferHandler {
|
|||||||
Log.logError(t);
|
Log.logError(t);
|
||||||
closed = true;
|
closed = true;
|
||||||
client2.deleteConnection(this);
|
client2.deleteConnection(this);
|
||||||
Collection<Stream> c = streams.values();
|
List<Stream> c = new LinkedList<>(streams.values());
|
||||||
for (Stream s : c) {
|
for (Stream s : c) {
|
||||||
s.cancelImpl(t);
|
s.cancelImpl(t);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.io.IOException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
@ -537,7 +538,7 @@ class Stream extends ExchangeImpl {
|
|||||||
* getResponseAsync()
|
* getResponseAsync()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final List<CompletableFuture<HttpResponseImpl>> response_cfs = new LinkedList<>();
|
final List<CompletableFuture<HttpResponseImpl>> response_cfs = new ArrayList<>(5);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
CompletableFuture<HttpResponseImpl> getResponseAsync(Void v) {
|
CompletableFuture<HttpResponseImpl> getResponseAsync(Void v) {
|
||||||
@ -565,17 +566,16 @@ class Stream extends ExchangeImpl {
|
|||||||
void completeResponse(HttpResponse r) {
|
void completeResponse(HttpResponse r) {
|
||||||
HttpResponseImpl resp = (HttpResponseImpl)r;
|
HttpResponseImpl resp = (HttpResponseImpl)r;
|
||||||
synchronized (response_cfs) {
|
synchronized (response_cfs) {
|
||||||
for (CompletableFuture<HttpResponseImpl> cf : response_cfs) {
|
int cfs_len = response_cfs.size();
|
||||||
|
for (int i=0; i<cfs_len; i++) {
|
||||||
|
CompletableFuture<HttpResponseImpl> cf = response_cfs.get(i);
|
||||||
if (!cf.isDone()) {
|
if (!cf.isDone()) {
|
||||||
cf.complete(resp);
|
cf.complete(resp);
|
||||||
response_cfs.remove(cf);
|
response_cfs.remove(cf);
|
||||||
//responseHeaders = new HttpHeadersImpl(); // for any following header blocks
|
|
||||||
return;
|
return;
|
||||||
} else
|
}
|
||||||
System.err.println("Stream: " + this + " ALREADY DONE");
|
|
||||||
}
|
}
|
||||||
response_cfs.add(CompletableFuture.completedFuture(resp));
|
response_cfs.add(CompletableFuture.completedFuture(resp));
|
||||||
//responseHeaders = new HttpHeadersImpl(); // for any following header blocks
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8140450
|
* @bug 8140450 8152893
|
||||||
* @summary Basic test for StackWalker.getCallerClass()
|
* @summary Basic test for StackWalker.getCallerClass()
|
||||||
* @run main/othervm GetCallerClassTest
|
* @run main/othervm GetCallerClassTest
|
||||||
* @run main/othervm GetCallerClassTest sm
|
* @run main/othervm GetCallerClassTest sm
|
||||||
@ -41,6 +41,7 @@ import java.security.Permissions;
|
|||||||
import java.security.Policy;
|
import java.security.Policy;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GetCallerClassTest {
|
public class GetCallerClassTest {
|
||||||
@ -65,16 +66,20 @@ public class GetCallerClassTest {
|
|||||||
}
|
}
|
||||||
new GetCallerClassTest(StackWalker.getInstance(), true).test();
|
new GetCallerClassTest(StackWalker.getInstance(), true).test();
|
||||||
new GetCallerClassTest(StackWalker.getInstance(RETAIN_CLASS_REFERENCE), false).test();
|
new GetCallerClassTest(StackWalker.getInstance(RETAIN_CLASS_REFERENCE), false).test();
|
||||||
|
new GetCallerClassTest(StackWalker.getInstance(EnumSet.of(RETAIN_CLASS_REFERENCE,
|
||||||
|
SHOW_HIDDEN_FRAMES)), false).test();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
new TopLevelCaller().run();
|
new TopLevelCaller().run();
|
||||||
|
new LambdaTest().run();
|
||||||
new Nested().createNestedCaller().run();
|
new Nested().createNestedCaller().run();
|
||||||
new InnerClassCaller().run();
|
new InnerClassCaller().run();
|
||||||
new ReflectionTest().run();
|
new ReflectionTest().run();
|
||||||
|
|
||||||
List<Thread> threads = Arrays.asList(
|
List<Thread> threads = Arrays.asList(
|
||||||
new Thread(new TopLevelCaller()),
|
new Thread(new TopLevelCaller()),
|
||||||
|
new Thread(new LambdaTest()),
|
||||||
new Thread(new Nested().createNestedCaller()),
|
new Thread(new Nested().createNestedCaller()),
|
||||||
new Thread(new InnerClassCaller()),
|
new Thread(new InnerClassCaller()),
|
||||||
new Thread(new ReflectionTest())
|
new Thread(new ReflectionTest())
|
||||||
@ -149,7 +154,7 @@ public class GetCallerClassTest {
|
|||||||
|
|
||||||
public static void assertEquals(Class<?> c, Class<?> expected) {
|
public static void assertEquals(Class<?> c, Class<?> expected) {
|
||||||
if (expected != c) {
|
if (expected != c) {
|
||||||
throw new RuntimeException(c + " != " + expected);
|
throw new RuntimeException("Got " + c + ", but expected " + expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +177,28 @@ public class GetCallerClassTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LambdaTest implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
Runnable lambdaRunnable = () -> {
|
||||||
|
try {
|
||||||
|
Class<?> c = walker.getCallerClass();
|
||||||
|
|
||||||
|
assertEquals(c, LambdaTest.class);
|
||||||
|
if (expectUOE) { // Should have thrown
|
||||||
|
throw new RuntimeException("Didn't get expected exception");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
if (expectUOE && causeIsUOE(e)) {
|
||||||
|
return; /* expected */
|
||||||
|
}
|
||||||
|
System.err.println("Unexpected exception:");
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
lambdaRunnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Nested {
|
class Nested {
|
||||||
NestedClassCaller createNestedCaller() { return new NestedClassCaller(); }
|
NestedClassCaller createNestedCaller() { return new NestedClassCaller(); }
|
||||||
class NestedClassCaller implements Runnable {
|
class NestedClassCaller implements Runnable {
|
||||||
|
72
jdk/test/java/lang/StackWalker/NativeMethod.java
Normal file
72
jdk/test/java/lang/StackWalker/NativeMethod.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8157892 8157977
|
||||||
|
* @summary Verify file name, line number and bci of native methods
|
||||||
|
* @run main NativeMethod
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.lang.StackWalker.Option;
|
||||||
|
import java.lang.StackWalker.StackFrame;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class NativeMethod {
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
|
new NativeMethod().test();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final StackWalker walker;
|
||||||
|
NativeMethod() {
|
||||||
|
this.walker = StackWalker.getInstance(Option.SHOW_REFLECT_FRAMES);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test() throws Exception {
|
||||||
|
// invoke via reflection that includes native methods
|
||||||
|
Method m = NativeMethod.class.getDeclaredMethod("walk");
|
||||||
|
m.invoke(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void walk() {
|
||||||
|
List<StackFrame> nativeFrames = walker.walk(s ->
|
||||||
|
s.filter(StackFrame::isNativeMethod)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
|
||||||
|
assertTrue(nativeFrames.size() > 0, "native frame not found");
|
||||||
|
for (StackFrame f : nativeFrames) {
|
||||||
|
assertTrue(f.getFileName() != null, "source file expected to be found");
|
||||||
|
assertTrue(f.getLineNumber() < 0, "line number expected to be unavailable");
|
||||||
|
assertTrue(f.getByteCodeIndex() < 0, "bci expected to be unavailable");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertTrue(boolean value, String msg) {
|
||||||
|
if (value != true)
|
||||||
|
throw new AssertionError(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @summary unit tests for java.lang.invoke.MethodHandles
|
* @summary unit tests for java.lang.invoke.MethodHandles
|
||||||
* @run testng/othervm -ea -esa test.java.lang.invoke.DropArgumentsTest
|
* @run testng test.java.lang.invoke.DropArgumentsTest
|
||||||
*/
|
*/
|
||||||
package test.java.lang.invoke;
|
package test.java.lang.invoke;
|
||||||
|
|
||||||
@ -87,4 +87,13 @@ public class DropArgumentsTest {
|
|||||||
public void dropArgumentsToMatchIAE(MethodHandle target, int pos, List<Class<?>> valueType, int skip) {
|
public void dropArgumentsToMatchIAE(MethodHandle target, int pos, List<Class<?>> valueType, int skip) {
|
||||||
MethodHandles.dropArgumentsToMatch(target, pos, valueType , skip);
|
MethodHandles.dropArgumentsToMatch(target, pos, valueType , skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@ExpectedExceptions(IllegalArgumentException.class)
|
||||||
|
public void dropArgumentsToMatchTestWithVoid() throws Throwable {
|
||||||
|
MethodHandle cat = lookup().findVirtual(String.class, "concat",
|
||||||
|
MethodType.methodType(String.class, String.class));
|
||||||
|
MethodType bigTypewithVoid = cat.type().insertParameterTypes(0, void.class, String.class, int.class);
|
||||||
|
MethodHandle handle2 = MethodHandles.dropArgumentsToMatch(cat, 0, bigTypewithVoid.parameterList(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @summary Unit test for java.net.CookieManager
|
* @summary Unit test for java.net.CookieManager
|
||||||
* @bug 6244040 7150552 7051862
|
* @bug 6244040 7150552 7051862
|
||||||
|
* @modules jdk.httpserver
|
||||||
* @run main/othervm -ea CookieManagerTest
|
* @run main/othervm -ea CookieManagerTest
|
||||||
* @author Edward Wang
|
* @author Edward Wang
|
||||||
*/
|
*/
|
||||||
@ -32,12 +33,31 @@
|
|||||||
import com.sun.net.httpserver.*;
|
import com.sun.net.httpserver.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
import static java.net.Proxy.NO_PROXY;
|
||||||
|
|
||||||
public class CookieManagerTest {
|
public class CookieManagerTest {
|
||||||
|
|
||||||
static CookieTransactionHandler httpTrans;
|
static CookieTransactionHandler httpTrans;
|
||||||
static HttpServer server;
|
static HttpServer server;
|
||||||
|
|
||||||
|
static final String hostAddress = getAddr();
|
||||||
|
|
||||||
|
/** Returns an IP literal suitable for use by the test. */
|
||||||
|
static String getAddr() {
|
||||||
|
try {
|
||||||
|
InetAddress lh = InetAddress.getLocalHost();
|
||||||
|
System.out.println("Trying: " + lh);
|
||||||
|
if (lh.isReachable(5_000)) {
|
||||||
|
System.out.println("Using: " + lh);
|
||||||
|
return lh.getHostAddress();
|
||||||
|
}
|
||||||
|
} catch (IOException x) {
|
||||||
|
System.out.println("Debug: caught:" + x);
|
||||||
|
}
|
||||||
|
System.out.println("Using: \"127.0.0.1\"");
|
||||||
|
return "127.0.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
startHttpServer();
|
startHttpServer();
|
||||||
makeHttpCall();
|
makeHttpCall();
|
||||||
@ -78,8 +98,8 @@ public class CookieManagerTest {
|
|||||||
|
|
||||||
public static void makeHttpCall() throws IOException {
|
public static void makeHttpCall() throws IOException {
|
||||||
try {
|
try {
|
||||||
System.out.println("http server listenining on: "
|
int port = server.getAddress().getPort();
|
||||||
+ server.getAddress().getPort());
|
System.out.println("http server listenining on: " + port);
|
||||||
|
|
||||||
// install CookieManager to use
|
// install CookieManager to use
|
||||||
CookieHandler.setDefault(new CookieManager());
|
CookieHandler.setDefault(new CookieManager());
|
||||||
@ -92,11 +112,12 @@ public class CookieManagerTest {
|
|||||||
((CookieManager)CookieHandler.getDefault())
|
((CookieManager)CookieHandler.getDefault())
|
||||||
.getCookieStore().removeAll();
|
.getCookieStore().removeAll();
|
||||||
URL url = new URL("http" ,
|
URL url = new URL("http" ,
|
||||||
InetAddress.getLocalHost().getHostAddress(),
|
hostAddress,
|
||||||
server.getAddress().getPort(),
|
server.getAddress().getPort(),
|
||||||
CookieTransactionHandler.testCases[i][0]
|
CookieTransactionHandler.testCases[i][0]
|
||||||
.serverPath);
|
.serverPath);
|
||||||
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
|
System.out.println("Requesting " + url);
|
||||||
|
HttpURLConnection uc = (HttpURLConnection)url.openConnection(NO_PROXY);
|
||||||
uc.getResponseCode();
|
uc.getResponseCode();
|
||||||
uc.disconnect();
|
uc.disconnect();
|
||||||
}
|
}
|
||||||
@ -116,8 +137,6 @@ class CookieTransactionHandler implements HttpHandler {
|
|||||||
// to send http request
|
// to send http request
|
||||||
public static final int testCount = 6;
|
public static final int testCount = 6;
|
||||||
|
|
||||||
private String localHostAddr = "127.0.0.1";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(HttpExchange exchange) throws IOException {
|
public void handle(HttpExchange exchange) throws IOException {
|
||||||
if (testDone < testCases[testcaseDone].length) {
|
if (testDone < testCases[testcaseDone].length) {
|
||||||
@ -188,10 +207,8 @@ class CookieTransactionHandler implements HttpHandler {
|
|||||||
testCases = new CookieTestCase[testCount][];
|
testCases = new CookieTestCase[testCount][];
|
||||||
testPolicies = new CookiePolicy[testCount];
|
testPolicies = new CookiePolicy[testCount];
|
||||||
|
|
||||||
try {
|
String localHostAddr = CookieManagerTest.hostAddress;
|
||||||
localHostAddr = InetAddress.getLocalHost().getHostAddress();
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
};
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
// an http session with Netscape cookies exchanged
|
// an http session with Netscape cookies exchanged
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 7128648
|
* @bug 7128648
|
||||||
|
* @modules jdk.httpserver
|
||||||
* @summary HttpURLConnection.getHeaderFields should return an unmodifiable Map
|
* @summary HttpURLConnection.getHeaderFields should return an unmodifiable Map
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
@ -40,6 +40,7 @@ import com.sun.net.httpserver.HttpExchange;
|
|||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
import com.sun.net.httpserver.HttpServer;
|
import com.sun.net.httpserver.HttpServer;
|
||||||
import com.sun.net.httpserver.Headers;
|
import com.sun.net.httpserver.Headers;
|
||||||
|
import static java.net.Proxy.NO_PROXY;
|
||||||
|
|
||||||
public class UnmodifiableMaps {
|
public class UnmodifiableMaps {
|
||||||
|
|
||||||
@ -47,8 +48,7 @@ public class UnmodifiableMaps {
|
|||||||
HttpServer server = startHttpServer();
|
HttpServer server = startHttpServer();
|
||||||
try {
|
try {
|
||||||
InetSocketAddress address = server.getAddress();
|
InetSocketAddress address = server.getAddress();
|
||||||
URI uri = new URI("http://" + InetAddress.getLocalHost().getHostAddress()
|
URI uri = new URI("http://localhost:" + address.getPort() + "/foo");
|
||||||
+ ":" + address.getPort() + "/foo");
|
|
||||||
doClient(uri);
|
doClient(uri);
|
||||||
} finally {
|
} finally {
|
||||||
server.stop(0);
|
server.stop(0);
|
||||||
@ -56,7 +56,7 @@ public class UnmodifiableMaps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void doClient(URI uri) throws Exception {
|
void doClient(URI uri) throws Exception {
|
||||||
HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection();
|
HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection(NO_PROXY);
|
||||||
|
|
||||||
// Test1: getRequestProperties is unmodifiable
|
// Test1: getRequestProperties is unmodifiable
|
||||||
System.out.println("Check getRequestProperties");
|
System.out.println("Check getRequestProperties");
|
||||||
|
@ -32,6 +32,7 @@ import java.net.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import sun.net.www.content.text.*;
|
import sun.net.www.content.text.*;
|
||||||
import sun.net.www.MessageHeader;
|
import sun.net.www.MessageHeader;
|
||||||
|
import static java.net.Proxy.NO_PROXY;
|
||||||
|
|
||||||
public class HandleContentTypeWithAttrs {
|
public class HandleContentTypeWithAttrs {
|
||||||
|
|
||||||
@ -39,13 +40,11 @@ public class HandleContentTypeWithAttrs {
|
|||||||
|
|
||||||
public HandleContentTypeWithAttrs (int port) throws Exception {
|
public HandleContentTypeWithAttrs (int port) throws Exception {
|
||||||
|
|
||||||
String localHostName = InetAddress.getLocalHost().getHostName();
|
|
||||||
|
|
||||||
// Request echo.html from myHttpServer.
|
// Request echo.html from myHttpServer.
|
||||||
// In the header of the response, we make
|
// In the header of the response, we make
|
||||||
// the content type have some attributes.
|
// the content type have some attributes.
|
||||||
url = new URL("http://" + localHostName + ":" + port + "/echo.html");
|
url = new URL("http://localhost:" + port + "/echo.html");
|
||||||
URLConnection urlConn = url.openConnection();
|
URLConnection urlConn = url.openConnection(NO_PROXY);
|
||||||
|
|
||||||
// the method getContent() calls the method
|
// the method getContent() calls the method
|
||||||
// getContentHandler(). With the fix, the method
|
// getContentHandler(). With the fix, the method
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @bug 4118056
|
* @bug 4118056
|
||||||
|
* @key intermittent
|
||||||
*
|
*
|
||||||
* @summary synopsis: Distributed Garbage Collection Deadlock
|
* @summary synopsis: Distributed Garbage Collection Deadlock
|
||||||
* @author Laird Dornin
|
* @author Laird Dornin
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2015, 2016, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# @test
|
||||||
|
# @bug 8044767
|
||||||
|
# @summary Basic test for ResourceBundle with modules; named module "test"
|
||||||
|
# contains resource bundles for root and en, and separate named modules
|
||||||
|
# "eubundles" and "asiabundles" contain other resource bundles.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$TESTJAVA" ]; then
|
||||||
|
if [ $# -lt 1 ]; then exit 1; fi
|
||||||
|
TESTJAVA="$1"; shift
|
||||||
|
COMPILEJAVA="${TESTJAVA}"
|
||||||
|
TESTSRC="`pwd`"
|
||||||
|
TESTCLASSES="`pwd`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
JAVAC="$COMPILEJAVA/bin/javac"
|
||||||
|
JAVA="$TESTJAVA/bin/java"
|
||||||
|
|
||||||
|
|
||||||
|
for I in eu asia
|
||||||
|
do
|
||||||
|
B=${I}bundles
|
||||||
|
mkdir -p mods/$B
|
||||||
|
CLASSES="`find $TESTSRC/src/$B -name '*.java'`"
|
||||||
|
if [ "x$CLASSES" != x ]; then
|
||||||
|
$JAVAC -g -d mods -modulesourcepath $TESTSRC/src -cp mods/test $CLASSES
|
||||||
|
fi
|
||||||
|
PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`"
|
||||||
|
if [ "x$PROPS" != x ]; then
|
||||||
|
for P in $PROPS
|
||||||
|
do
|
||||||
|
D=`dirname $P`
|
||||||
|
mkdir -p mods/$B/$D
|
||||||
|
cp $TESTSRC/src/$B/$P mods/$B/$D/
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p mods/test
|
||||||
|
$JAVAC -g -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
|
||||||
|
|
||||||
|
$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de
|
||||||
|
|
||||||
|
exit $?
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -23,23 +23,33 @@
|
|||||||
|
|
||||||
package jdk.test.resources.asia;
|
package jdk.test.resources.asia;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.ResourceBundle.Control;
|
import java.util.Set;
|
||||||
import jdk.test.resources.MyControl;
|
import java.util.spi.AbstractResourceBundleProvider;
|
||||||
|
|
||||||
import jdk.test.resources.MyResourcesProvider;
|
import jdk.test.resources.MyResourcesProvider;
|
||||||
|
|
||||||
public class MyResourcesAsia extends MyControl implements MyResourcesProvider {
|
public class MyResourcesAsia extends AbstractResourceBundleProvider
|
||||||
|
implements MyResourcesProvider
|
||||||
|
{
|
||||||
|
private static Set<Locale> asiaLocales
|
||||||
|
= Set.of(Locale.JAPANESE, Locale.CHINESE, Locale.TAIWAN);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toBundleName(String baseName, Locale locale) {
|
||||||
|
String bundleName = super.toBundleName(baseName, locale);
|
||||||
|
if (asiaLocales.contains(locale)) {
|
||||||
|
int index = bundleName.lastIndexOf('.');
|
||||||
|
return bundleName.substring(0, index + 1) + "asia" + bundleName.substring(index);
|
||||||
|
}
|
||||||
|
return bundleName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceBundle getBundle(String baseName, Locale locale) {
|
public ResourceBundle getBundle(String baseName, Locale locale) {
|
||||||
if (isAsiaLocale(locale)) {
|
if (asiaLocales.contains(locale)) {
|
||||||
try {
|
return super.getBundle(baseName, locale);
|
||||||
ClassLoader loader = MyResourcesAsia.class.getClassLoader();
|
|
||||||
return newBundle(baseName, locale, "java.properties", loader, false);
|
|
||||||
} catch (IllegalAccessException | InstantiationException | IOException e) {
|
|
||||||
System.out.println(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -23,23 +23,36 @@
|
|||||||
|
|
||||||
package jdk.test.resources.eu;
|
package jdk.test.resources.eu;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.ResourceBundle.Control;
|
import java.util.Set;
|
||||||
import jdk.test.resources.MyControl;
|
import java.util.spi.AbstractResourceBundleProvider;
|
||||||
|
|
||||||
import jdk.test.resources.MyResourcesProvider;
|
import jdk.test.resources.MyResourcesProvider;
|
||||||
|
|
||||||
public class MyResourcesEU extends MyControl implements MyResourcesProvider {
|
public class MyResourcesEU extends AbstractResourceBundleProvider
|
||||||
|
implements MyResourcesProvider
|
||||||
|
{
|
||||||
|
private static final Set<Locale> euLocales = Set.of(Locale.GERMAN, Locale.FRENCH);
|
||||||
|
|
||||||
|
public MyResourcesEU() {
|
||||||
|
super("java.class");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toBundleName(String baseName, Locale locale) {
|
||||||
|
String bundleName = super.toBundleName(baseName, locale);
|
||||||
|
if (euLocales.contains(locale)) {
|
||||||
|
int index = bundleName.lastIndexOf('.');
|
||||||
|
return bundleName.substring(0, index + 1) + "eu" + bundleName.substring(index);
|
||||||
|
}
|
||||||
|
return bundleName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceBundle getBundle(String baseName, Locale locale) {
|
public ResourceBundle getBundle(String baseName, Locale locale) {
|
||||||
if (isEULocale(locale)) {
|
if (euLocales.contains(locale)) {
|
||||||
try {
|
return super.getBundle(baseName, locale);
|
||||||
ClassLoader loader = MyResourcesEU.class.getClassLoader();
|
|
||||||
return newBundle(baseName, locale, "java.class", loader, false);
|
|
||||||
} catch (IllegalAccessException | InstantiationException | IOException e) {
|
|
||||||
System.out.println(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* 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 jdk.test.resources;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class MyControl extends ResourceBundle.Control {
|
|
||||||
private static final Set<Locale> euLocales, asiaLocales;
|
|
||||||
|
|
||||||
static {
|
|
||||||
euLocales = new HashSet<>(Arrays.asList(Locale.GERMAN, Locale.FRENCH));
|
|
||||||
asiaLocales = new HashSet<>(Arrays.asList(Locale.JAPANESE, Locale.CHINESE, Locale.TAIWAN));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toBundleName(String baseName, Locale locale) {
|
|
||||||
String bundleName = baseName;
|
|
||||||
if (euLocales.contains(locale)) {
|
|
||||||
bundleName = addRegion(baseName, "eu");
|
|
||||||
} else if (asiaLocales.contains(locale)) {
|
|
||||||
bundleName = addRegion(baseName, "asia");
|
|
||||||
}
|
|
||||||
return super.toBundleName(bundleName, locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String addRegion(String baseName, String region) {
|
|
||||||
int index = baseName.lastIndexOf('.');
|
|
||||||
return baseName.substring(0, index + 1) + region + baseName.substring(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isEULocale(Locale locale) {
|
|
||||||
return euLocales.contains(locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isAsiaLocale(Locale locale) {
|
|
||||||
return asiaLocales.contains(locale);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, 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
|
||||||
@ -23,19 +23,20 @@
|
|||||||
|
|
||||||
package jdk.test.resources;
|
package jdk.test.resources;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.spi.AbstractResourceBundleProvider;
|
||||||
|
|
||||||
public class MyResourcesProviderImpl extends MyControl implements MyResourcesProvider {
|
public class MyResourcesProviderImpl extends AbstractResourceBundleProvider
|
||||||
|
implements MyResourcesProvider
|
||||||
|
{
|
||||||
|
public MyResourcesProviderImpl() {
|
||||||
|
super("java.class");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResourceBundle getBundle(String baseName, Locale locale) {
|
public ResourceBundle getBundle(String baseName, Locale locale) {
|
||||||
if (locale.equals(Locale.ENGLISH) || locale.equals(Locale.ROOT)) {
|
if (locale.equals(Locale.ENGLISH) || locale.equals(Locale.ROOT)) {
|
||||||
try {
|
return super.getBundle(baseName, locale);
|
||||||
ClassLoader loader = MyResourcesProviderImpl.class.getClassLoader();
|
|
||||||
return newBundle(baseName, locale, "java.class", loader, false);
|
|
||||||
} catch (IllegalAccessException | InstantiationException | IOException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590
|
* 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590
|
||||||
* 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
|
* 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
|
||||||
* 8151481 4867170 7080302 6728861 6995635 6736245 4916384
|
* 8151481 4867170 7080302 6728861 6995635 6736245 4916384
|
||||||
* 6328855 6192895 6345469 6988218 6693451 7006761 8140212 8143282
|
* 6328855 6192895 6345469 6988218 6693451 7006761 8140212 8143282 8158482
|
||||||
*
|
*
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @build jdk.testlibrary.*
|
* @build jdk.testlibrary.*
|
||||||
@ -164,6 +164,7 @@ public class RegExTest {
|
|||||||
groupCurlyBackoffTest();
|
groupCurlyBackoffTest();
|
||||||
patternAsPredicate();
|
patternAsPredicate();
|
||||||
invalidFlags();
|
invalidFlags();
|
||||||
|
embeddedFlags();
|
||||||
grapheme();
|
grapheme();
|
||||||
expoBacktracking();
|
expoBacktracking();
|
||||||
|
|
||||||
@ -4675,6 +4676,24 @@ public class RegExTest {
|
|||||||
report("Invalid compile flags");
|
report("Invalid compile flags");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test is for 8158482
|
||||||
|
private static void embeddedFlags() throws Exception {
|
||||||
|
try {
|
||||||
|
Pattern.compile("(?i).(?-i).");
|
||||||
|
Pattern.compile("(?m).(?-m).");
|
||||||
|
Pattern.compile("(?s).(?-s).");
|
||||||
|
Pattern.compile("(?d).(?-d).");
|
||||||
|
Pattern.compile("(?u).(?-u).");
|
||||||
|
Pattern.compile("(?c).(?-c).");
|
||||||
|
Pattern.compile("(?x).(?-x).");
|
||||||
|
Pattern.compile("(?U).(?-U).");
|
||||||
|
Pattern.compile("(?imsducxU).(?-imsducxU).");
|
||||||
|
} catch (PatternSyntaxException x) {
|
||||||
|
failCount++;
|
||||||
|
}
|
||||||
|
report("Embedded flags");
|
||||||
|
}
|
||||||
|
|
||||||
private static void grapheme() throws Exception {
|
private static void grapheme() throws Exception {
|
||||||
Files.lines(Paths.get(System.getProperty("test.src", "."),
|
Files.lines(Paths.get(System.getProperty("test.src", "."),
|
||||||
"GraphemeBreakTest.txt"))
|
"GraphemeBreakTest.txt"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user