Merge
This commit is contained in:
commit
8865ea58f1
nashorn
@ -36,6 +36,7 @@ import java.io.PrintWriter;
|
|||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@ -75,8 +76,8 @@ public final class Source implements Loggable {
|
|||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base directory the File or base part of the URL. Used to implement __DIR__.
|
* Base path or URL of this source. Used to implement __DIR__, which can be
|
||||||
* Used to load scripts relative to the 'directory' or 'base' URL of current script.
|
* used to load scripts relative to the location of the current script.
|
||||||
* This will be null when it can't be computed.
|
* This will be null when it can't be computed.
|
||||||
*/
|
*/
|
||||||
private final String base;
|
private final String base;
|
||||||
@ -875,31 +876,25 @@ public final class Source implements Loggable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the base url. This is currently used for testing only
|
* Returns the base directory or URL for the given URL. Used to implement __DIR__.
|
||||||
* @param url a URL
|
* @param url a URL
|
||||||
* @return base URL for url
|
* @return base path or URL, or null if argument is not a hierarchical URL
|
||||||
*/
|
*/
|
||||||
public static String baseURL(final URL url) {
|
public static String baseURL(final URL url) {
|
||||||
if (url.getProtocol().equals("file")) {
|
try {
|
||||||
try {
|
final URI uri = url.toURI();
|
||||||
final Path path = Paths.get(url.toURI());
|
|
||||||
|
if (uri.getScheme().equals("file")) {
|
||||||
|
final Path path = Paths.get(uri);
|
||||||
final Path parent = path.getParent();
|
final Path parent = path.getParent();
|
||||||
return (parent != null) ? (parent + File.separator) : null;
|
return (parent != null) ? (parent + File.separator) : null;
|
||||||
} catch (final SecurityException | URISyntaxException | IOError e) {
|
}
|
||||||
|
if (uri.isOpaque() || uri.getPath() == null || uri.getPath().isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
return uri.resolve("").toString();
|
||||||
|
|
||||||
// FIXME: is there a better way to find 'base' URL of a given URL?
|
} catch (final SecurityException | URISyntaxException | IOError e) {
|
||||||
String path = url.getPath();
|
|
||||||
if (path.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
path = path.substring(0, path.lastIndexOf('/') + 1);
|
|
||||||
final int port = url.getPort();
|
|
||||||
try {
|
|
||||||
return new URL(url.getProtocol(), url.getHost(), port, path).toString();
|
|
||||||
} catch (final MalformedURLException e) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,19 +118,6 @@ ifdef JPRT_PRODUCT_VM_ARGS
|
|||||||
JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
|
JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# jtreg -nativepath <dir>
|
|
||||||
#
|
|
||||||
# Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true
|
|
||||||
# should be JPRT_TESTNATIVE_PATH
|
|
||||||
ifdef TEST_IMAGE_DIR
|
|
||||||
TESTNATIVE_DIR = $(TEST_IMAGE_DIR)
|
|
||||||
else ifdef JPRT_TESTNATIVE_PATH
|
|
||||||
TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH)
|
|
||||||
endif
|
|
||||||
ifdef TESTNATIVE_DIR
|
|
||||||
JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/nashorn/jtreg/native")
|
|
||||||
endif
|
|
||||||
|
|
||||||
# jtreg failure handler config
|
# jtreg failure handler config
|
||||||
ifeq ($(FAILURE_HANDLER_DIR), )
|
ifeq ($(FAILURE_HANDLER_DIR), )
|
||||||
ifneq ($(TESTNATIVE_DIR), )
|
ifneq ($(TESTNATIVE_DIR), )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user