From 20b5d3aa4f7ca76d5226095f24439400fb80315d Mon Sep 17 00:00:00 2001
From: Roland Westrelin
Date: Fri, 3 May 2013 09:32:50 +0200
Subject: [PATCH 001/147] 8012037: Test8009761.java "Failed: init recursive
calls: 7224. After deopt 58824"
Test shouldn't be run with a modified CompileThreshold
Reviewed-by: kvn
---
hotspot/test/compiler/8009761/Test8009761.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hotspot/test/compiler/8009761/Test8009761.java b/hotspot/test/compiler/8009761/Test8009761.java
index f588b82cd23..401458b6b92 100644
--- a/hotspot/test/compiler/8009761/Test8009761.java
+++ b/hotspot/test/compiler/8009761/Test8009761.java
@@ -25,7 +25,7 @@
* @test
* @bug 8009761
* @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
- * @run main/othervm -Xmixed -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8009761
+ * @run main/othervm -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
*
*/
@@ -249,7 +249,7 @@ public class Test8009761 {
System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count);
System.exit(97);
} else {
- System.out.println("PASSED");
+ System.out.println("PASSED " + c1);
}
}
}
From 34da1742ef0967a692d1474c4ec8aed2b758034e Mon Sep 17 00:00:00 2001
From: Gilles Duboscq
Date: Wed, 24 Apr 2013 14:26:09 +0200
Subject: [PATCH 002/147] 8012292: optimized build with GCC broken
Some #ifndef PRODUCT should be #ifdef ASSERT
Reviewed-by: kvn, twisti
---
hotspot/make/jprt.properties | 6 +++---
hotspot/src/share/vm/classfile/classFileParser.cpp | 4 ++--
hotspot/src/share/vm/classfile/vmSymbols.cpp | 4 ++--
hotspot/src/share/vm/opto/runtime.cpp | 6 ++----
hotspot/src/share/vm/utilities/quickSort.cpp | 2 ++
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/hotspot/make/jprt.properties b/hotspot/make/jprt.properties
index af7f321b722..5971546c6d9 100644
--- a/hotspot/make/jprt.properties
+++ b/hotspot/make/jprt.properties
@@ -134,14 +134,14 @@ jprt.my.windows.x64=${jprt.my.windows.x64.${jprt.tools.default.release}}
jprt.build.targets.standard= \
${jprt.my.solaris.sparc}-{product|fastdebug}, \
- ${jprt.my.solaris.sparcv9}-{product|fastdebug}, \
+ ${jprt.my.solaris.sparcv9}-{product|fastdebug|optimized}, \
${jprt.my.solaris.i586}-{product|fastdebug}, \
${jprt.my.solaris.x64}-{product|fastdebug}, \
${jprt.my.linux.i586}-{product|fastdebug}, \
- ${jprt.my.linux.x64}-{product|fastdebug}, \
+ ${jprt.my.linux.x64}-{product|fastdebug|optimized}, \
${jprt.my.macosx.x64}-{product|fastdebug}, \
${jprt.my.windows.i586}-{product|fastdebug}, \
- ${jprt.my.windows.x64}-{product|fastdebug}, \
+ ${jprt.my.windows.x64}-{product|fastdebug|optimized}, \
${jprt.my.linux.armvh}-{product|fastdebug}
jprt.build.targets.open= \
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index 373ca0ae8ff..6f8e8f11b96 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -3046,7 +3046,7 @@ AnnotationArray* ClassFileParser::assemble_annotations(u1* runtime_visible_annot
}
-#ifndef PRODUCT
+#ifdef ASSERT
static void parseAndPrintGenericSignatures(
instanceKlassHandle this_klass, TRAPS) {
assert(ParseAllGenericSignatures == true, "Shouldn't call otherwise");
@@ -3071,7 +3071,7 @@ static void parseAndPrintGenericSignatures(
}
}
}
-#endif // ndef PRODUCT
+#endif // def ASSERT
instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index,
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp
index 92939ea2487..cc38c6d2cd6 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp
@@ -49,7 +49,7 @@ extern "C" {
}
}
-#ifndef PRODUCT
+#ifdef ASSERT
#define VM_SYMBOL_ENUM_NAME_BODY(name, string) #name "\0"
static const char* vm_symbol_enum_names =
VM_SYMBOLS_DO(VM_SYMBOL_ENUM_NAME_BODY, VM_ALIAS_IGNORE)
@@ -64,7 +64,7 @@ static const char* vm_symbol_enum_name(vmSymbols::SID sid) {
}
return string;
}
-#endif //PRODUCT
+#endif //ASSERT
// Put all the VM symbol strings in one place.
// Makes for a more compact libjvm.
diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp
index 7edb97e0bba..d0aefad66b7 100644
--- a/hotspot/src/share/vm/opto/runtime.cpp
+++ b/hotspot/src/share/vm/opto/runtime.cpp
@@ -126,17 +126,15 @@ ExceptionBlob* OptoRuntime::_exception_blob;
// This should be called in an assertion at the start of OptoRuntime routines
// which are entered from compiled code (all of them)
-#ifndef PRODUCT
+#ifdef ASSERT
static bool check_compiled_frame(JavaThread* thread) {
assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
-#ifdef ASSERT
RegisterMap map(thread, false);
frame caller = thread->last_frame().sender(&map);
assert(caller.is_compiled_frame(), "not being called from compiled like code");
-#endif /* ASSERT */
return true;
}
-#endif
+#endif // ASSERT
#define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \
diff --git a/hotspot/src/share/vm/utilities/quickSort.cpp b/hotspot/src/share/vm/utilities/quickSort.cpp
index e3cfa1efa5e..9cdda333530 100644
--- a/hotspot/src/share/vm/utilities/quickSort.cpp
+++ b/hotspot/src/share/vm/utilities/quickSort.cpp
@@ -32,6 +32,7 @@
#include "utilities/quickSort.hpp"
#include
+#ifdef ASSERT
static int test_comparator(int a, int b) {
if (a == b) {
return 0;
@@ -41,6 +42,7 @@ static int test_comparator(int a, int b) {
}
return 1;
}
+#endif // ASSERT
static int test_even_odd_comparator(int a, int b) {
bool a_is_odd = (a % 2) == 1;
From ab18b431cb462044537f361ab0ef875c0b8e76a7 Mon Sep 17 00:00:00 2001
From: James Laskey
Date: Tue, 30 Apr 2013 10:05:42 -0300
Subject: [PATCH 003/147] 8006220: Simplify PropertyMaps
Reviewed-by: hannesw, lagergren
---
.../nashorn/internal/codegen/MapCreator.java | 6 +-
.../codegen/ObjectClassGenerator.java | 10 +
.../internal/codegen/ObjectCreator.java | 13 +-
.../nashorn/internal/objects/NativeDebug.java | 60 ----
.../internal/objects/NativeJSAdapter.java | 6 +-
.../internal/runtime/AccessorProperty.java | 15 +-
.../jdk/nashorn/internal/runtime/Context.java | 3 -
.../nashorn/internal/runtime/Property.java | 23 +-
.../internal/runtime/PropertyHashMap.java | 4 +-
.../nashorn/internal/runtime/PropertyMap.java | 194 ++++++------
.../internal/runtime/ScriptObject.java | 286 +++++++-----------
.../internal/runtime/SetMethodCreator.java | 28 +-
.../internal/runtime/SpillProperty.java | 85 ------
.../internal/runtime/StructureLoader.java | 3 +-
.../runtime/UserAccessorProperty.java | 9 +-
.../src/jdk/nashorn/internal/scripts/JO.java | 3 +-
nashorn/src/jdk/nashorn/tools/Shell.java | 2 +-
17 files changed, 267 insertions(+), 483 deletions(-)
delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/SpillProperty.java
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java b/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java
index 00f3f80f55b..153e0367f3f 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java
@@ -65,10 +65,12 @@ public class MapCreator {
* Constructs a property map based on a set of fields.
*
* @param hasArguments does the created object have an "arguments" property
+ * @param fieldCount Number of fields in use.
+ * @param fieldMaximum Number of fields available.
*
* @return New map populated with accessor properties.
*/
- PropertyMap makeMap(final boolean hasArguments) {
+ PropertyMap makeMap(final boolean hasArguments, final int fieldCount, final int fieldMaximum) {
final List properties = new ArrayList<>();
assert keys != null;
@@ -82,7 +84,7 @@ public class MapCreator {
}
}
- return PropertyMap.newMap(structure, properties);
+ return PropertyMap.newMap(structure, properties, fieldCount, fieldMaximum);
}
/**
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java
index b75145262b7..172c1035426 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java
@@ -68,6 +68,16 @@ public final class ObjectClassGenerator {
*/
static final String SCOPE_MARKER = "P";
+ /**
+ * Minimum number of extra fields in an object.
+ */
+ static final int FIELD_PADDING = 4;
+
+ /**
+ * Rounding when calculating the number of fields.
+ */
+ static final int FIELD_ROUNDING = 4;
+
/**
* Debug field logger
* Should we print debugging information for fields when they are generated and getters/setters are called?
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/ObjectCreator.java b/nashorn/src/jdk/nashorn/internal/codegen/ObjectCreator.java
index a9c494ccab0..82efd14c4fa 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/ObjectCreator.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/ObjectCreator.java
@@ -26,6 +26,8 @@
package jdk.nashorn.internal.codegen;
import java.util.List;
+import static jdk.nashorn.internal.codegen.ObjectClassGenerator.FIELD_PADDING;
+import static jdk.nashorn.internal.codegen.ObjectClassGenerator.FIELD_ROUNDING;
import jdk.nashorn.internal.ir.Symbol;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.PropertyMap;
@@ -50,6 +52,7 @@ public abstract class ObjectCreator {
private final boolean isScope;
private final boolean hasArguments;
private int fieldCount;
+ private int paddedFieldCount;
private int paramCount;
private String fieldObjectClassName;
private Class> fieldObjectClass;
@@ -88,6 +91,8 @@ public abstract class ObjectCreator {
}
}
}
+
+ paddedFieldCount = (fieldCount + FIELD_PADDING + FIELD_ROUNDING - 1) / FIELD_ROUNDING * FIELD_ROUNDING;
}
/**
@@ -96,7 +101,7 @@ public abstract class ObjectCreator {
private void findClass() {
fieldObjectClassName = isScope() ?
ObjectClassGenerator.getClassName(fieldCount, paramCount) :
- ObjectClassGenerator.getClassName(fieldCount);
+ ObjectClassGenerator.getClassName(paddedFieldCount);
try {
this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName));
@@ -125,11 +130,7 @@ public abstract class ObjectCreator {
* @return the newly created property map
*/
protected PropertyMap makeMap() {
- if (keys.isEmpty()) { //empty map
- propertyMap = PropertyMap.newMap(fieldObjectClass);
- } else {
- propertyMap = newMapCreator(fieldObjectClass).makeMap(hasArguments());
- }
+ propertyMap = newMapCreator(fieldObjectClass).makeMap(hasArguments(), fieldCount, paddedFieldCount);
return propertyMap;
}
diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
index aba76c8e9fe..337f2e3d5b1 100644
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
@@ -86,66 +86,6 @@ public final class NativeDebug extends ScriptObject {
return UNDEFINED;
}
- /**
- * Nashorn extension: get embed0 from {@link ScriptObject}
- *
- * @param self self reference
- * @param obj script object
- * @return the embed0 property value for the given ScriptObject
- */
- @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object embed0(final Object self, final Object obj) {
- if (obj instanceof ScriptObject) {
- return ((ScriptObject)obj).embed0;
- }
- return UNDEFINED;
- }
-
- /**
- * Nashorn extension: get embed1 from {@link ScriptObject}
- *
- * @param self self reference
- * @param obj script object
- * @return the embed1 property value for the given ScriptObject
- */
- @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object embed1(final Object self, final Object obj) {
- if (obj instanceof ScriptObject) {
- return ((ScriptObject)obj).embed1;
- }
- return UNDEFINED;
- }
-
- /**
- * Nashorn extension: get embed2 from {@link ScriptObject}
- *
- * @param self self reference
- * @param obj script object
- * @return the embed2 property value for the given ScriptObject
- */
- @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object embed2(final Object self, final Object obj) {
- if (obj instanceof ScriptObject) {
- return ((ScriptObject)obj).embed2;
- }
- return UNDEFINED;
- }
-
- /**
- * Nashorn extension: get embed3 from {@link ScriptObject}
- *
- * @param self self reference
- * @param obj script object
- * @return the embed3 property value for the given ScriptObject
- */
- @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object embed3(final Object self, final Object obj) {
- if (obj instanceof ScriptObject) {
- return ((ScriptObject)obj).embed3;
- }
- return UNDEFINED;
- }
-
/**
* Nashorn extension: get spill vector from {@link ScriptObject}
*
diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java b/nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
index 8a3f42d2c1c..153db769f9b 100644
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
@@ -620,7 +620,7 @@ public final class NativeJSAdapter extends ScriptObject {
// to name. Probably not a big deal, but if we can ever make it leaner, it'd be nice.
return new GuardedInvocation(MH.dropArguments(MH.constant(Object.class,
func.makeBoundFunction(this, new Object[] { name })), 0, Object.class),
- adaptee.getMap().getProtoGetSwitchPoint(__call__), testJSAdaptor(adaptee, null, null, null));
+ adaptee.getMap().getProtoGetSwitchPoint(adaptee.getProto(), __call__), testJSAdaptor(adaptee, null, null, null));
}
throw typeError("no.such.function", desc.getNameToken(2), ScriptRuntime.safeToString(this));
default:
@@ -687,7 +687,7 @@ public final class NativeJSAdapter extends ScriptObject {
if (methodHandle != null) {
return new GuardedInvocation(
methodHandle,
- adaptee.getMap().getProtoGetSwitchPoint(hook),
+ adaptee.getMap().getProtoGetSwitchPoint(adaptee.getProto(), hook),
testJSAdaptor(adaptee, findData.getGetter(Object.class), findData.getOwner(), func));
}
}
@@ -699,7 +699,7 @@ public final class NativeJSAdapter extends ScriptObject {
final MethodHandle methodHandle = hook.equals(__put__) ?
MH.asType(Lookup.EMPTY_SETTER, type) :
Lookup.emptyGetter(type.returnType());
- return new GuardedInvocation(methodHandle, adaptee.getMap().getProtoGetSwitchPoint(hook), testJSAdaptor(adaptee, null, null, null));
+ return new GuardedInvocation(methodHandle, adaptee.getMap().getProtoGetSwitchPoint(adaptee.getProto(), hook), testJSAdaptor(adaptee, null, null, null));
}
}
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java
index b0ca46f78f9..38effdafd55 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java
@@ -50,8 +50,6 @@ import jdk.nashorn.internal.lookup.MethodHandleFactory;
/**
* An AccessorProperty is the most generic property type. An AccessorProperty is
* represented as fields in a ScriptObject class.
- *
- * @see SpillProperty
*/
public class AccessorProperty extends Property {
private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
@@ -77,6 +75,7 @@ public class AccessorProperty extends Property {
private static final MethodType[] ACCESSOR_GETTER_TYPES = new MethodType[NOOF_TYPES];
private static final MethodType[] ACCESSOR_SETTER_TYPES = new MethodType[NOOF_TYPES];
+ private static final MethodHandle SPILLGETTER = MH.asType(MH.getter(MethodHandles.lookup(), ScriptObject.class, "spill", Object[].class), Lookup.GET_OBJECT_TYPE);
/** Seed getter for the primitive version of this field (in -Dnashorn.fields.dual=true mode) */
private MethodHandle primitiveGetter;
@@ -285,7 +284,7 @@ public class AccessorProperty extends Property {
"get");
}
- return getters[i];
+ return isSpill() ? MH.filterArguments(getters[i], 0, SPILLGETTER) : getters[i];
}
private Property getWiderProperty(final Class> type) {
@@ -327,6 +326,7 @@ public class AccessorProperty extends Property {
final Class> forType = currentType == null ? type : currentType;
//if we are asking for an object setter, but are still a primitive type, we might try to box it
+ MethodHandle mh;
if (needsInvalidator(i, ci)) {
final Property newProperty = getWiderProperty(type);
@@ -335,12 +335,15 @@ public class AccessorProperty extends Property {
final MethodHandle explodeTypeSetter = MH.filterArguments(widerSetter, 0, MH.insertArguments(REPLACE_MAP, 1, newMap, getKey(), currentType, type));
if (currentType != null && currentType.isPrimitive() && type == Object.class) {
//might try a box check on this to avoid widening field to object storage
- return createGuardBoxedPrimitiveSetter(currentType, generateSetter(currentType, currentType), explodeTypeSetter);
+ mh = createGuardBoxedPrimitiveSetter(currentType, generateSetter(currentType, currentType), explodeTypeSetter);
+ } else {
+ mh = explodeTypeSetter;
}
- return explodeTypeSetter;
+ } else {
+ mh = generateSetter(forType, type);
}
- return generateSetter(forType, type);
+ return isSpill() ? MH.filterArguments(mh, 0, SPILLGETTER) : mh;
}
@Override
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java
index 40fe1ba15df..c3d32d0ba72 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java
@@ -201,9 +201,6 @@ public final class Context {
/** Current error manager. */
private final ErrorManager errors;
- /** Empty map used for seed map for JO objects */
- final PropertyMap emptyMap = PropertyMap.newEmptyMap(this);
-
private static final ClassLoader myLoader = Context.class.getClassLoader();
private static final StructureLoader sharedLoader;
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Property.java b/nashorn/src/jdk/nashorn/internal/runtime/Property.java
index dfb8bf5d642..585fc4b3113 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/Property.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Property.java
@@ -41,7 +41,6 @@ import jdk.nashorn.internal.codegen.types.Type;
*
* @see PropertyMap
* @see AccessorProperty
- * @see SpillProperty
* @see UserAccessorProperty
*/
public abstract class Property {
@@ -64,7 +63,7 @@ public abstract class Property {
private static final int MODIFY_MASK = 0b0000_0000_1111;
- /** Is this a spill property? See {@link SpillProperty} */
+ /** Is this a spill property? See {@link AccessorProperty} */
public static final int IS_SPILL = 0b0000_0001_0000;
/** Is this a function parameter? */
@@ -88,7 +87,7 @@ public abstract class Property {
/** Property flags. */
protected int flags;
- /** Property field number or spill slot */
+ /** Property field number or spill slot. */
private final int slot;
/**
@@ -248,7 +247,7 @@ public abstract class Property {
* Does this property use any slots in the spill array described in
* {@link Property#isSpill}? In that case how many. Currently a property
* only uses max one spill slot, but this may change in future representations
- * Only {@link SpillProperty} instances use spill slots
+ * Only {@link AccessorProperty} instances use spill slots
*
* @return number of spill slots a property is using
*/
@@ -344,6 +343,14 @@ public abstract class Property {
return key;
}
+ /**
+ * Get the field number or spill slot
+ * @return number/slot, -1 if none exists
+ */
+ public int getSlot() {
+ return slot;
+ }
+
/**
* Abstract method for retrieving the setter for the property. We do not know
* anything about the internal representation when we request the setter, we only
@@ -388,14 +395,6 @@ public abstract class Property {
return null;
}
- /**
- * Get the field number or spill slot
- * @return number/slot, -1 if none exists
- */
- public int getSlot() {
- return slot;
- }
-
@Override
public int hashCode() {
final Class> type = getCurrentType();
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyHashMap.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyHashMap.java
index 6e41fd56827..bfa06920ae3 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyHashMap.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyHashMap.java
@@ -110,7 +110,7 @@ public final class PropertyHashMap implements Map {
private static final int LIST_THRESHOLD = 8;
/** Initial map. */
- public static final PropertyHashMap EMPTY_MAP = new PropertyHashMap();
+ public static final PropertyHashMap EMPTY_HASHMAP = new PropertyHashMap();
/** Number of properties in the map. */
private final int size;
@@ -246,7 +246,7 @@ public final class PropertyHashMap implements Map {
}
} else if (findElement(list, key) != null) {
final int newSize = size - 1;
- return newSize != 0 ? new PropertyHashMap(newSize, null, removeFromList(list, key)) : EMPTY_MAP;
+ return newSize != 0 ? new PropertyHashMap(newSize, null, removeFromList(list, key)) : EMPTY_HASHMAP;
}
return this;
}
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java
index b5154c853f6..c01ceae0d18 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java
@@ -25,7 +25,7 @@
package jdk.nashorn.internal.runtime;
-import static jdk.nashorn.internal.runtime.PropertyHashMap.EMPTY_MAP;
+import static jdk.nashorn.internal.runtime.PropertyHashMap.EMPTY_HASHMAP;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.SwitchPoint;
@@ -49,29 +49,27 @@ import java.util.WeakHashMap;
* will return a new map.
*/
public final class PropertyMap implements Iterable
*/
-public class Checker extends DocTreeScanner {
+public class Checker extends DocTreePathScanner {
final Env env;
Set foundParams = new HashSet();
@@ -152,7 +152,7 @@ public class Checker extends DocTreeScanner {
foundInheritDoc = false;
foundReturn = false;
- scan(tree, (Void) null);
+ scan(new DocTreePath(p, tree), null);
if (!isOverridingMethod) {
switch (env.currElement.getKind()) {
@@ -620,47 +620,36 @@ public class Checker extends DocTreeScanner {
}
@Override
+ @SuppressWarnings("fallthrough")
public Void visitParam(ParamTree tree, Void ignore) {
boolean typaram = tree.isTypeParameter();
IdentifierTree nameTree = tree.getName();
- Element e = env.currElement;
- switch (e.getKind()) {
- case METHOD: case CONSTRUCTOR: {
- ExecutableElement ee = (ExecutableElement) e;
- checkParamDeclared(nameTree, typaram ? ee.getTypeParameters() : ee.getParameters());
- break;
- }
+ Element paramElement = nameTree != null ? env.trees.getElement(new DocTreePath(getCurrentPath(), nameTree)) : null;
- case CLASS: case INTERFACE: {
- TypeElement te = (TypeElement) e;
- if (typaram) {
- checkParamDeclared(nameTree, te.getTypeParameters());
- } else {
- env.messages.error(REFERENCE, tree, "dc.invalid.param");
+ if (paramElement == null) {
+ switch (env.currElement.getKind()) {
+ case CLASS: case INTERFACE: {
+ if (!typaram) {
+ env.messages.error(REFERENCE, tree, "dc.invalid.param");
+ break;
+ }
+ }
+ case METHOD: case CONSTRUCTOR: {
+ env.messages.error(REFERENCE, nameTree, "dc.param.name.not.found");
+ break;
}
- break;
- }
- default:
- env.messages.error(REFERENCE, tree, "dc.invalid.param");
- break;
+ default:
+ env.messages.error(REFERENCE, tree, "dc.invalid.param");
+ break;
+ }
+ } else {
+ foundParams.add(paramElement);
}
+
warnIfEmpty(tree, tree.getDescription());
return super.visitParam(tree, ignore);
}
- // where
- private void checkParamDeclared(IdentifierTree nameTree, List extends Element> list) {
- Name name = nameTree.getName();
- boolean found = false;
- for (Element e: list) {
- if (name.equals(e.getSimpleName())) {
- foundParams.add(e);
- found = true;
- }
- }
- if (!found)
- env.messages.error(REFERENCE, nameTree, "dc.param.name.not.found");
- }
private void checkParamsDocumented(List extends Element> list) {
if (foundInheritDoc)
@@ -678,7 +667,7 @@ public class Checker extends DocTreeScanner {
@Override
public Void visitReference(ReferenceTree tree, Void ignore) {
- Element e = env.trees.getElement(env.currPath, tree);
+ Element e = env.trees.getElement(getCurrentPath());
if (e == null)
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
return super.visitReference(tree, ignore);
@@ -716,7 +705,7 @@ public class Checker extends DocTreeScanner {
@Override
public Void visitThrows(ThrowsTree tree, Void ignore) {
ReferenceTree exName = tree.getExceptionName();
- Element ex = env.trees.getElement(env.currPath, exName);
+ Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName));
if (ex == null) {
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
} else if (ex.asType().getKind() == TypeKind.DECLARED
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
index 545b883f7f0..d8d367bf77e 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
@@ -33,6 +33,7 @@ import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
@@ -44,12 +45,12 @@ import javax.tools.JavaFileObject;
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocTree;
-import com.sun.source.doctree.ReferenceTree;
import com.sun.source.tree.CatchTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Scope;
import com.sun.source.tree.Tree;
import com.sun.source.util.DocSourcePositions;
+import com.sun.source.util.DocTreePath;
import com.sun.source.util.DocTreeScanner;
import com.sun.source.util.DocTrees;
import com.sun.source.util.JavacTask;
@@ -314,7 +315,7 @@ public class JavacTrees extends DocTrees {
return TreePath.getPath(treeTopLevel.snd, treeTopLevel.fst);
}
- public Element getElement(TreePath path) {
+ public Symbol getElement(TreePath path) {
JCTree tree = (JCTree) path.getLeaf();
Symbol sym = TreeInfo.symbolFor(tree);
if (sym == null) {
@@ -343,11 +344,19 @@ public class JavacTrees extends DocTrees {
}
@Override
- public Element getElement(TreePath path, ReferenceTree reference) {
- if (!(reference instanceof DCReference))
- return null;
- DCReference ref = (DCReference) reference;
+ public Element getElement(DocTreePath path) {
+ DocTree forTree = path.getLeaf();
+ if (forTree instanceof DCReference)
+ return attributeDocReference(path.getTreePath(), ((DCReference) forTree));
+ if (forTree instanceof DCIdentifier) {
+ if (path.getParentPath().getLeaf() instanceof DCParam) {
+ return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
+ }
+ }
+ return null;
+ }
+ private Symbol attributeDocReference(TreePath path, DCReference ref) {
Env env = getAttrContext(path);
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
@@ -427,6 +436,30 @@ public class JavacTrees extends DocTrees {
}
}
+ private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
+ Symbol javadocSymbol = getElement(path);
+ if (javadocSymbol == null)
+ return null;
+ ElementKind kind = javadocSymbol.getKind();
+ List extends Symbol> params = List.nil();
+ if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
+ MethodSymbol ee = (MethodSymbol) javadocSymbol;
+ params = ptag.isTypeParameter()
+ ? ee.getTypeParameters()
+ : ee.getParameters();
+ } else if (kind.isClass() || kind.isInterface()) {
+ ClassSymbol te = (ClassSymbol) javadocSymbol;
+ params = te.getTypeParameters();
+ }
+
+ for (Symbol param : params) {
+ if (param.getSimpleName() == ptag.getName().getName()) {
+ return param;
+ }
+ }
+ return null;
+ }
+
/** @see com.sun.tools.javadoc.ClassDocImpl#findField */
private VarSymbol findField(ClassSymbol tsym, Name fieldName) {
return searchField(tsym, fieldName, new HashSet());
diff --git a/langtools/test/tools/javac/doctree/DocTreePathScannerTest.java b/langtools/test/tools/javac/doctree/DocTreePathScannerTest.java
new file mode 100644
index 00000000000..5261a0a858f
--- /dev/null
+++ b/langtools/test/tools/javac/doctree/DocTreePathScannerTest.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013, 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 8009724
+ * @summary adding DocTreePath and DocTreePathScanner
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTree.Kind;
+import com.sun.source.doctree.DocTreeVisitor;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreePath;
+import com.sun.source.util.DocTreePathScanner;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.api.JavacTool;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+public class DocTreePathScannerTest {
+ public static void main(String... args) throws Exception {
+ DocTreePathScannerTest t = new DocTreePathScannerTest();
+ t.run();
+ }
+
+ void run() throws Exception {
+ List files = new ArrayList();
+ File testSrc = new File(System.getProperty("test.src"));
+ for (File f: testSrc.listFiles()) {
+ if (f.isFile() && f.getName().endsWith(".java"))
+ files.add(f);
+ }
+
+ JavacTool javac = JavacTool.create();
+ StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+
+ Iterable extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+ JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+ DocTrees trees = DocTrees.instance(t);
+
+ Iterable extends CompilationUnitTree> units = t.parse();
+
+ DeclScanner ds = new DeclScanner(trees);
+ for (CompilationUnitTree unit: units) {
+ ds.scan(unit, null);
+ }
+
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ }
+
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+
+ class DeclScanner extends TreePathScanner {
+ DocTrees trees;
+ DocTreePathScanner cs;
+
+ DeclScanner(DocTrees trees) {
+ this.trees = trees;
+ cs = new CommentPathScanner();
+ }
+
+ @Override
+ public Void visitClass(ClassTree tree, Void ignore) {
+ super.visitClass(tree, ignore);
+ visitDecl(tree, tree.getSimpleName());
+ return null;
+ }
+
+ @Override
+ public Void visitMethod(MethodTree tree, Void ignore) {
+ super.visitMethod(tree, ignore);
+ visitDecl(tree, tree.getName());
+ return null;
+ }
+
+ @Override
+ public Void visitVariable(VariableTree tree, Void ignore) {
+ super.visitVariable(tree, ignore);
+ visitDecl(tree, tree.getName());
+ return null;
+ }
+
+ void visitDecl(Tree tree, Name name) {
+ TreePath path = getCurrentPath();
+ DocCommentTree dc = trees.getDocCommentTree(path);
+ if (dc != null)
+ cs.scan(new DocTreePath(path, dc), null);
+ }
+ }
+
+ class CommentPathScanner extends DocTreePathScanner {
+ CommentPathScanner() {}
+
+ @Override
+ public Void scan(final DocTree tree, Void ignore) {
+ if (tree != null) {
+ DocTree previous = null;
+ for (DocTree current : getCurrentPath()) {
+ if (previous != null) {
+ final List children = new ArrayList<>();
+ current.accept(new DocTreeScanner() {
+ @Override public Void scan(DocTree node, Void p) {
+ children.add(node);
+ return null;
+ }
+ }, null);
+
+ if (!children.contains(previous)) {
+ error("Invalid DocTreePath for: " + tree);
+ }
+ }
+
+ previous = current;
+ }
+ }
+ return super.scan(tree, ignore);
+ }
+ }
+
+}
diff --git a/langtools/test/tools/javac/doctree/ReferenceTest.java b/langtools/test/tools/javac/doctree/ReferenceTest.java
index ee987ece007..944a1328e19 100644
--- a/langtools/test/tools/javac/doctree/ReferenceTest.java
+++ b/langtools/test/tools/javac/doctree/ReferenceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -36,6 +36,8 @@ import com.sun.source.doctree.LinkTree;
import com.sun.source.doctree.ReferenceTree;
import com.sun.source.doctree.SeeTree;
import com.sun.source.doctree.TextTree;
+import com.sun.source.util.DocTreePath;
+import com.sun.source.util.DocTreePathScanner;
import com.sun.source.util.DocTreeScanner;
import com.sun.source.util.DocTrees;
import com.sun.source.util.TreePath;
@@ -125,7 +127,7 @@ public class ReferenceTest extends AbstractProcessor {
return true;
}
- class DocCommentScanner extends DocTreeScanner {
+ class DocCommentScanner extends DocTreePathScanner {
TreePath path;
DocCommentTree dc;
@@ -135,7 +137,7 @@ public class ReferenceTest extends AbstractProcessor {
void scan() {
dc = trees.getDocCommentTree(path);
- scan(dc, null);
+ scan(new DocTreePath(path, dc), null);
}
@Override
@@ -158,7 +160,7 @@ public class ReferenceTest extends AbstractProcessor {
void checkReference(ReferenceTree tree, List extends DocTree> label) {
String sig = tree.getSignature();
- Element found = trees.getElement(path, tree);
+ Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree));
if (found == null) {
System.err.println(sig + " NOT FOUND");
} else {
From c76e4b0e466a04e0488cd1f3903f465b9b192077 Mon Sep 17 00:00:00 2001
From: Daniel Fuchs
Date: Mon, 6 May 2013 18:50:16 +0200
Subject: [PATCH 018/147] 8008738: Issue in
com.sun.org.apache.xml.internal.serializer.Encodings causes some JCK tests to
fail intermittently
Encodings.java sometimes creates EncodingInfo objects whose java names are not recognized by the Charset API. This patch fixes that issue.
Reviewed-by: joehw, alanb
---
.../xml/internal/serializer/Encodings.java | 367 +++++++++++-------
1 file changed, 235 insertions(+), 132 deletions(-)
diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java
index 35845697a32..d4d95ff8cf2 100644
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java
@@ -33,6 +33,14 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;
import java.util.StringTokenizer;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Map.Entry;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
@@ -79,36 +87,17 @@ public final class Encodings extends Object
throws UnsupportedEncodingException
{
- for (int i = 0; i < _encodings.length; ++i)
- {
- if (_encodings[i].name.equalsIgnoreCase(encoding))
- {
- try
- {
- return new BufferedWriter(new OutputStreamWriter(
- output,
- _encodings[i].javaName));
- }
- catch (java.lang.IllegalArgumentException iae) // java 1.1.8
- {
- // keep trying
- }
- catch (UnsupportedEncodingException usee)
- {
-
- // keep trying
- }
+ final EncodingInfo ei = _encodingInfos.findEncoding(toUpperCaseFast(encoding));
+ if (ei != null) {
+ try {
+ return new BufferedWriter(new OutputStreamWriter(
+ output, ei.javaName));
+ } catch (UnsupportedEncodingException usee) {
+ // keep trying
}
}
- try
- {
- return new BufferedWriter(new OutputStreamWriter(output, encoding));
- }
- catch (java.lang.IllegalArgumentException iae) // java 1.1.8
- {
- throw new UnsupportedEncodingException(encoding);
- }
+ return new BufferedWriter(new OutputStreamWriter(output, encoding));
}
@@ -141,12 +130,24 @@ public final class Encodings extends Object
EncodingInfo ei;
String normalizedEncoding = toUpperCaseFast(encoding);
- ei = (EncodingInfo) _encodingTableKeyJava.get(normalizedEncoding);
- if (ei == null)
- ei = (EncodingInfo) _encodingTableKeyMime.get(normalizedEncoding);
+ ei = _encodingInfos.findEncoding(normalizedEncoding);
if (ei == null) {
// We shouldn't have to do this, but just in case.
- ei = new EncodingInfo(null,null);
+ try {
+ // This may happen if the caller tries to use
+ // an encoding that wasn't registered in the
+ // (java name)->(preferred mime name) mapping file.
+ // In that case we attempt to load the charset for the
+ // given encoding, and if that succeeds - we create a new
+ // EncodingInfo instance - assuming the canonical name
+ // of the charset can be used as the mime name.
+ final Charset c = Charset.forName(encoding);
+ final String name = c.name();
+ ei = new EncodingInfo(name, name);
+ _encodingInfos.putEncoding(normalizedEncoding, ei);
+ } catch (IllegalCharsetNameException | UnsupportedCharsetException x) {
+ ei = new EncodingInfo(null,null);
+ }
}
return ei;
@@ -269,8 +270,8 @@ public final class Encodings extends Object
*/
private static String convertJava2MimeEncoding(String encoding)
{
- EncodingInfo enc =
- (EncodingInfo) _encodingTableKeyJava.get(encoding.toUpperCase());
+ final EncodingInfo enc =
+ _encodingInfos.getEncodingFromJavaKey(toUpperCaseFast(encoding));
if (null != enc)
return enc.name;
return encoding;
@@ -285,38 +286,37 @@ public final class Encodings extends Object
*/
public static String convertMime2JavaEncoding(String encoding)
{
-
- for (int i = 0; i < _encodings.length; ++i)
- {
- if (_encodings[i].name.equalsIgnoreCase(encoding))
- {
- return _encodings[i].javaName;
- }
- }
-
- return encoding;
+ final EncodingInfo info = _encodingInfos.findEncoding(toUpperCaseFast(encoding));
+ return info != null ? info.javaName : encoding;
}
- /**
- * Load a list of all the supported encodings.
- *
- * System property "encodings" formatted using URL syntax may define an
- * external encodings list. Thanks to Sergey Ushakov for the code
- * contribution!
- */
- private static EncodingInfo[] loadEncodingInfo()
- {
- try
- {
+ // Using an inner static class here prevent initialization races
+ // where the hash maps could be used before they were populated.
+ //
+ private final static class EncodingInfos {
+ // These maps are final and not modified after initialization.
+ private final Map _encodingTableKeyJava = new HashMap<>();
+ private final Map _encodingTableKeyMime = new HashMap<>();
+ // This map will be added to after initialization: make sure it's
+ // thread-safe. This map should not be used frequently - only in cases
+ // where the mapping requested was not declared in the Encodings.properties
+ // file.
+ private final Map _encodingDynamicTable =
+ Collections.synchronizedMap(new HashMap());
+
+ private EncodingInfos() {
+ loadEncodingInfo();
+ }
+
+ // Opens the file/resource containing java charset name -> preferred mime
+ // name mapping and returns it as an InputStream.
+ private InputStream openEncodingsFileStream() throws MalformedURLException, IOException {
String urlString = null;
InputStream is = null;
- try
- {
+ try {
urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
- }
- catch (SecurityException e)
- {
+ } catch (SecurityException e) {
}
if (urlString != null && urlString.length() > 0) {
@@ -327,84 +327,188 @@ public final class Encodings extends Object
if (is == null) {
is = SecuritySupport.getResourceAsStream(ENCODINGS_FILE);
}
+ return is;
+ }
+ // Loads the Properties resource containing the mapping:
+ // java charset name -> preferred mime name
+ // and returns it.
+ private Properties loadProperties() throws MalformedURLException, IOException {
Properties props = new Properties();
- if (is != null) {
- props.load(is);
- is.close();
- } else {
- // Seems to be no real need to force failure here, let the
- // system do its best... The issue is not really very critical,
- // and the output will be in any case _correct_ though maybe not
- // always human-friendly... :)
- // But maybe report/log the resource problem?
- // Any standard ways to report/log errors (in static context)?
- }
-
- int totalEntries = props.size();
- int totalMimeNames = 0;
- Enumeration keys = props.keys();
- for (int i = 0; i < totalEntries; ++i)
- {
- String javaName = (String) keys.nextElement();
- String val = props.getProperty(javaName);
- totalMimeNames++;
- int pos = val.indexOf(' ');
- for (int j = 0; j < pos; ++j)
- if (val.charAt(j) == ',')
- totalMimeNames++;
- }
- EncodingInfo[] ret = new EncodingInfo[totalMimeNames];
- int j = 0;
- keys = props.keys();
- for (int i = 0; i < totalEntries; ++i)
- {
- String javaName = (String) keys.nextElement();
- String val = props.getProperty(javaName);
- int pos = val.indexOf(' ');
- String mimeName;
- //int lastPrintable;
- if (pos < 0)
- {
- // Maybe report/log this problem?
- // "Last printable character not defined for encoding " +
- // mimeName + " (" + val + ")" ...
- mimeName = val;
- //lastPrintable = 0x00FF;
+ try (InputStream is = openEncodingsFileStream()) {
+ if (is != null) {
+ props.load(is);
+ } else {
+ // Seems to be no real need to force failure here, let the
+ // system do its best... The issue is not really very critical,
+ // and the output will be in any case _correct_ though maybe not
+ // always human-friendly... :)
+ // But maybe report/log the resource problem?
+ // Any standard ways to report/log errors (in static context)?
}
- else
- {
- //lastPrintable =
- // Integer.decode(val.substring(pos).trim()).intValue();
- StringTokenizer st =
- new StringTokenizer(val.substring(0, pos), ",");
- for (boolean first = true;
- st.hasMoreTokens();
- first = false)
- {
- mimeName = st.nextToken();
- ret[j] =
- new EncodingInfo(mimeName, javaName);
- _encodingTableKeyMime.put(
- mimeName.toUpperCase(),
- ret[j]);
- if (first)
- _encodingTableKeyJava.put(
- javaName.toUpperCase(),
- ret[j]);
- j++;
+ }
+ return props;
+ }
+
+ // Parses the mime list associated to a java charset name.
+ // The first mime name in the list is supposed to be the preferred
+ // mime name.
+ private String[] parseMimeTypes(String val) {
+ int pos = val.indexOf(' ');
+ //int lastPrintable;
+ if (pos < 0) {
+ // Maybe report/log this problem?
+ // "Last printable character not defined for encoding " +
+ // mimeName + " (" + val + ")" ...
+ return new String[] { val };
+ //lastPrintable = 0x00FF;
+ }
+ //lastPrintable =
+ // Integer.decode(val.substring(pos).trim()).intValue();
+ StringTokenizer st =
+ new StringTokenizer(val.substring(0, pos), ",");
+ String[] values = new String[st.countTokens()];
+ for (int i=0; st.hasMoreTokens(); i++) {
+ values[i] = st.nextToken();
+ }
+ return values;
+ }
+
+ // This method here attempts to find the canonical charset name for the
+ // the given name - which is supposed to be either a java name or a mime
+ // name.
+ // For that, it attempts to load the charset using the given name, and
+ // then returns the charset's canonical name.
+ // If the charset could not be loaded from the given name,
+ // the method returns null.
+ private String findCharsetNameFor(String name) {
+ try {
+ return Charset.forName(name).name();
+ } catch (Exception x) {
+ return null;
+ }
+ }
+
+ // This method here attempts to find the canonical charset name for the
+ // the set javaName+mimeNames - which are supposed to all refer to the
+ // same charset.
+ // For that it attempts to load the charset using the javaName, and if
+ // not found, attempts again using each of the mime names in turn.
+ // If the charset could be loaded from the javaName, then the javaName
+ // itself is returned as charset name. Otherwise, each of the mime names
+ // is tried in turn, until a charset can be loaded from one of the names,
+ // and the loaded charset's canonical name is returned.
+ // If no charset can be loaded from either the javaName or one of the
+ // mime names, then null is returned.
+ //
+ // Note that the returned name is the 'java' name that will be used in
+ // instances of EncodingInfo.
+ // This is important because EncodingInfo uses that 'java name' later on
+ // in calls to String.getBytes(javaName).
+ // As it happens, sometimes only one element of the set mime names/javaName
+ // is known by Charset: sometimes only one of the mime names is known,
+ // sometime only the javaName is known, sometimes all are known.
+ //
+ // By using this method here, we fix the problem where one of the mime
+ // names is known but the javaName is unknown, by associating the charset
+ // loaded from one of the mime names with the unrecognized javaName.
+ //
+ // When none of the mime names or javaName are known - there's not much we can
+ // do... It can mean that this encoding is not supported for this
+ // OS. If such a charset is ever use it will result in having all characters
+ // escaped.
+ //
+ private String findCharsetNameFor(String javaName, String[] mimes) {
+ String cs = findCharsetNameFor(javaName);
+ if (cs != null) return javaName;
+ for (String m : mimes) {
+ cs = findCharsetNameFor(m);
+ if (cs != null) break;
+ }
+ return cs;
+ }
+
+ /**
+ * Loads a list of all the supported encodings.
+ *
+ * System property "encodings" formatted using URL syntax may define an
+ * external encodings list. Thanks to Sergey Ushakov for the code
+ * contribution!
+ */
+ private void loadEncodingInfo() {
+ try {
+ // load (java name)->(preferred mime name) mapping.
+ final Properties props = loadProperties();
+
+ // create instances of EncodingInfo from the loaded mapping
+ Enumeration keys = props.keys();
+ Map canonicals = new HashMap<>();
+ while (keys.hasMoreElements()) {
+ final String javaName = (String) keys.nextElement();
+ final String[] mimes = parseMimeTypes(props.getProperty(javaName));
+
+ final String charsetName = findCharsetNameFor(javaName, mimes);
+ if (charsetName != null) {
+ final String kj = toUpperCaseFast(javaName);
+ final String kc = toUpperCaseFast(charsetName);
+ for (int i = 0; i < mimes.length; ++i) {
+ final String mimeName = mimes[i];
+ final String km = toUpperCaseFast(mimeName);
+ EncodingInfo info = new EncodingInfo(mimeName, charsetName);
+ _encodingTableKeyMime.put(km, info);
+ if (!canonicals.containsKey(kc)) {
+ // canonicals will map the charset name to
+ // the info containing the prefered mime name
+ // (the preferred mime name is the first mime
+ // name in the list).
+ canonicals.put(kc, info);
+ _encodingTableKeyJava.put(kc, info);
+ }
+ _encodingTableKeyJava.put(kj, info);
+ }
+ } else {
+ // None of the java or mime names on the line were
+ // recognized => this charset is not supported?
}
}
+
+ // Fix up the _encodingTableKeyJava so that the info mapped to
+ // the java name contains the preferred mime name.
+ // (a given java name can correspond to several mime name,
+ // but we want the _encodingTableKeyJava to point to the
+ // preferred mime name).
+ for (Entry e : _encodingTableKeyJava.entrySet()) {
+ e.setValue(canonicals.get(toUpperCaseFast(e.getValue().javaName)));
+ }
+
+ } catch (java.net.MalformedURLException mue) {
+ throw new com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException(mue);
+ } catch (java.io.IOException ioe) {
+ throw new com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException(ioe);
}
- return ret;
}
- catch (java.net.MalformedURLException mue)
- {
- throw new com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException(mue);
+
+ EncodingInfo findEncoding(String normalizedEncoding) {
+ EncodingInfo info = _encodingTableKeyJava.get(normalizedEncoding);
+ if (info == null) {
+ info = _encodingTableKeyMime.get(normalizedEncoding);
+ }
+ if (info == null) {
+ info = _encodingDynamicTable.get(normalizedEncoding);
+ }
+ return info;
}
- catch (java.io.IOException ioe)
- {
- throw new com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException(ioe);
+
+ EncodingInfo getEncodingFromMimeKey(String normalizedMimeName) {
+ return _encodingTableKeyMime.get(normalizedMimeName);
+ }
+
+ EncodingInfo getEncodingFromJavaKey(String normalizedJavaName) {
+ return _encodingTableKeyJava.get(normalizedJavaName);
+ }
+
+ void putEncoding(String key, EncodingInfo info) {
+ _encodingDynamicTable.put(key, info);
}
}
@@ -457,7 +561,6 @@ public final class Encodings extends Object
return codePoint;
}
- private static final HashMap _encodingTableKeyJava = new HashMap();
- private static final HashMap _encodingTableKeyMime = new HashMap();
- private static final EncodingInfo[] _encodings = loadEncodingInfo();
+ private final static EncodingInfos _encodingInfos = new EncodingInfos();
+
}
From 149097fbb751155cba49de38f8da5b39635198af Mon Sep 17 00:00:00 2001
From: Christian Thalinger
Date: Mon, 6 May 2013 13:53:13 -0700
Subject: [PATCH 019/147] 7196277: JSR 292: Two jck/runtime tests crash on
java.lang.invoke.MethodHandle.invokeExact
Reviewed-by: jrose, kvn
---
hotspot/src/share/vm/oops/method.cpp | 4 +-
hotspot/src/share/vm/prims/methodHandles.cpp | 58 ++++++++++++++++---
hotspot/src/share/vm/prims/nativeLookup.cpp | 5 +-
.../src/share/vm/runtime/sharedRuntime.cpp | 28 +++++----
4 files changed, 69 insertions(+), 26 deletions(-)
diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp
index 74364c3bd6a..68a55ef09ec 100644
--- a/hotspot/src/share/vm/oops/method.cpp
+++ b/hotspot/src/share/vm/oops/method.cpp
@@ -832,7 +832,9 @@ void Method::link_method(methodHandle h_method, TRAPS) {
assert(entry != NULL, "interpreter entry must be non-null");
// Sets both _i2i_entry and _from_interpreted_entry
set_interpreter_entry(entry);
- if (is_native() && !is_method_handle_intrinsic()) {
+
+ // Don't overwrite already registered native entries.
+ if (is_native() && !has_native_function()) {
set_native_function(
SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
!native_bind_event_is_interesting);
diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp
index 34104985237..2ef36f91447 100644
--- a/hotspot/src/share/vm/prims/methodHandles.cpp
+++ b/hotspot/src/share/vm/prims/methodHandles.cpp
@@ -1298,6 +1298,28 @@ JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobjec
}
JVM_END
+/**
+ * Throws a java/lang/UnsupportedOperationException unconditionally.
+ * This is required by the specification of MethodHandle.invoke if
+ * invoked directly.
+ */
+JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
+ THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively");
+ return NULL;
+}
+JVM_END
+
+/**
+ * Throws a java/lang/UnsupportedOperationException unconditionally.
+ * This is required by the specification of MethodHandle.invokeExact if
+ * invoked directly.
+ */
+JVM_ENTRY(jobject, MH_invokeExact_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
+ THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invokeExact cannot be invoked reflectively");
+ return NULL;
+}
+JVM_END
+
/// JVM_RegisterMethodHandleMethods
#undef CS // Solaris builds complain
@@ -1317,7 +1339,7 @@ JVM_END
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
// These are the native methods on java.lang.invoke.MethodHandleNatives.
-static JNINativeMethod required_methods_JDK8[] = {
+static JNINativeMethod MHN_methods[] = {
{CC"init", CC"("MEM""OBJ")V", FN_PTR(MHN_init_Mem)},
{CC"expand", CC"("MEM")V", FN_PTR(MHN_expand_Mem)},
{CC"resolve", CC"("MEM""CLS")"MEM, FN_PTR(MHN_resolve_Mem)},
@@ -1335,8 +1357,28 @@ static JNINativeMethod required_methods_JDK8[] = {
{CC"getMemberVMInfo", CC"("MEM")"OBJ, FN_PTR(MHN_getMemberVMInfo)}
};
-// This one function is exported, used by NativeLookup.
+static JNINativeMethod MH_methods[] = {
+ // UnsupportedOperationException throwers
+ {CC"invoke", CC"(["OBJ")"OBJ, FN_PTR(MH_invoke_UOE)},
+ {CC"invokeExact", CC"(["OBJ")"OBJ, FN_PTR(MH_invokeExact_UOE)}
+};
+/**
+ * Helper method to register native methods.
+ */
+static bool register_natives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) {
+ int status = env->RegisterNatives(clazz, methods, nMethods);
+ if (status != JNI_OK || env->ExceptionOccurred()) {
+ warning("JSR 292 method handle code is mismatched to this JVM. Disabling support.");
+ env->ExceptionClear();
+ return false;
+ }
+ return true;
+}
+
+/**
+ * This one function is exported, used by NativeLookup.
+ */
JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) {
if (!EnableInvokeDynamic) {
warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable.");
@@ -1354,16 +1396,14 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class))
MH_class = (jclass) JNIHandles::make_local(env, mirror);
}
- int status;
-
if (enable_MH) {
ThreadToNativeFromVM ttnfv(thread);
- status = env->RegisterNatives(MHN_class, required_methods_JDK8, sizeof(required_methods_JDK8)/sizeof(JNINativeMethod));
- if (status != JNI_OK || env->ExceptionOccurred()) {
- warning("JSR 292 method handle code is mismatched to this JVM. Disabling support.");
- enable_MH = false;
- env->ExceptionClear();
+ if (enable_MH) {
+ enable_MH = register_natives(env, MHN_class, MHN_methods, sizeof(MHN_methods)/sizeof(JNINativeMethod));
+ }
+ if (enable_MH) {
+ enable_MH = register_natives(env, MH_class, MH_methods, sizeof(MH_methods)/sizeof(JNINativeMethod));
}
}
diff --git a/hotspot/src/share/vm/prims/nativeLookup.cpp b/hotspot/src/share/vm/prims/nativeLookup.cpp
index 6162ae85032..990600eea27 100644
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp
@@ -383,10 +383,7 @@ address NativeLookup::lookup_base(methodHandle method, bool& in_base_library, TR
address NativeLookup::lookup(methodHandle method, bool& in_base_library, TRAPS) {
if (!method->has_native_function()) {
- address entry =
- method->intrinsic_id() == vmIntrinsics::_invokeGeneric ?
- SharedRuntime::native_method_throw_unsupported_operation_exception_entry() :
- lookup_base(method, in_base_library, CHECK_NULL);
+ address entry = lookup_base(method, in_base_library, CHECK_NULL);
method->set_native_function(entry,
Method::native_bind_event_is_interesting);
// -verbose:jni printing
diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp
index 57af1f3bda7..114f27d20a8 100644
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp
@@ -883,15 +883,23 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread,
}
-JNI_ENTRY(void, throw_unsatisfied_link_error(JNIEnv* env, ...))
+/**
+ * Throws an java/lang/UnsatisfiedLinkError. The address of this method is
+ * installed in the native function entry of all native Java methods before
+ * they get linked to their actual native methods.
+ *
+ * \note
+ * This method actually never gets called! The reason is because
+ * the interpreter's native entries call NativeLookup::lookup() which
+ * throws the exception when the lookup fails. The exception is then
+ * caught and forwarded on the return from NativeLookup::lookup() call
+ * before the call to the native function. This might change in the future.
+ */
+JNI_ENTRY(void*, throw_unsatisfied_link_error(JNIEnv* env, ...))
{
- THROW(vmSymbols::java_lang_UnsatisfiedLinkError());
-}
-JNI_END
-
-JNI_ENTRY(void, throw_unsupported_operation_exception(JNIEnv* env, ...))
-{
- THROW(vmSymbols::java_lang_UnsupportedOperationException());
+ // We return a bad value here to make sure that the exception is
+ // forwarded before we look at the return value.
+ THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badJNIHandle);
}
JNI_END
@@ -899,10 +907,6 @@ address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() {
return CAST_FROM_FN_PTR(address, &throw_unsatisfied_link_error);
}
-address SharedRuntime::native_method_throw_unsupported_operation_exception_entry() {
- return CAST_FROM_FN_PTR(address, &throw_unsupported_operation_exception);
-}
-
#ifndef PRODUCT
JRT_ENTRY(intptr_t, SharedRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2))
From 7c367a6025f519bf12b5b57c807470555eb0a673 Mon Sep 17 00:00:00 2001
From: Christian Thalinger
Date: Mon, 6 May 2013 19:49:23 -0700
Subject: [PATCH 020/147] 8008772: remove gamma launcher
Reviewed-by: kvn, neliasso, ctornqvi
---
hotspot/make/Makefile | 229 +-
hotspot/make/bsd/makefiles/buildtree.make | 32 +-
hotspot/make/bsd/makefiles/launcher.make | 115 -
hotspot/make/bsd/makefiles/vm.make | 3 -
.../launcher.script => make/hotspot.script} | 26 +-
hotspot/make/linux/makefiles/buildtree.make | 31 +-
hotspot/make/linux/makefiles/launcher.make | 93 -
hotspot/make/linux/makefiles/vm.make | 3 -
hotspot/make/solaris/makefiles/buildtree.make | 31 +-
hotspot/make/solaris/makefiles/launcher.make | 108 -
hotspot/make/solaris/makefiles/vm.make | 3 -
hotspot/make/windows/makefiles/debug.make | 3 +-
hotspot/make/windows/makefiles/fastdebug.make | 3 +-
hotspot/make/windows/makefiles/launcher.make | 73 -
hotspot/make/windows/makefiles/product.make | 3 +-
.../windows/makefiles/projectcreator.make | 2 -
.../make/windows/projectfiles/common/Makefile | 1 -
hotspot/src/os/posix/launcher/java_md.c | 1936 ---------------
hotspot/src/os/posix/launcher/java_md.h | 82 -
hotspot/src/os/windows/launcher/java_md.c | 1507 ------------
hotspot/src/os/windows/launcher/java_md.h | 83 -
.../tools/ProjectCreator/BuildConfig.java | 2 +
.../ProjectCreator/WinGammaPlatformVC10.java | 9 +-
hotspot/src/share/tools/launcher/java.c | 2080 -----------------
hotspot/src/share/tools/launcher/java.h | 110 -
hotspot/src/share/tools/launcher/jli_util.c | 89 -
hotspot/src/share/tools/launcher/jli_util.h | 35 -
hotspot/src/share/tools/launcher/wildcard.c | 496 ----
hotspot/src/share/tools/launcher/wildcard.h | 34 -
29 files changed, 137 insertions(+), 7085 deletions(-)
delete mode 100644 hotspot/make/bsd/makefiles/launcher.make
rename hotspot/{src/os/posix/launcher/launcher.script => make/hotspot.script} (89%)
delete mode 100644 hotspot/make/linux/makefiles/launcher.make
delete mode 100644 hotspot/make/solaris/makefiles/launcher.make
delete mode 100644 hotspot/make/windows/makefiles/launcher.make
delete mode 100644 hotspot/src/os/posix/launcher/java_md.c
delete mode 100644 hotspot/src/os/posix/launcher/java_md.h
delete mode 100644 hotspot/src/os/windows/launcher/java_md.c
delete mode 100644 hotspot/src/os/windows/launcher/java_md.h
delete mode 100644 hotspot/src/share/tools/launcher/java.c
delete mode 100644 hotspot/src/share/tools/launcher/java.h
delete mode 100644 hotspot/src/share/tools/launcher/jli_util.c
delete mode 100644 hotspot/src/share/tools/launcher/jli_util.h
delete mode 100644 hotspot/src/share/tools/launcher/wildcard.c
delete mode 100644 hotspot/src/share/tools/launcher/wildcard.h
diff --git a/hotspot/make/Makefile b/hotspot/make/Makefile
index e0d9826e468..526ed2393f2 100644
--- a/hotspot/make/Makefile
+++ b/hotspot/make/Makefile
@@ -151,32 +151,43 @@ else
$(MAKE_ARGS) BUILD_FLAVOR=product docs
endif
+# Output directories
+C1_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1
+C2_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2
+MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1
+ZERO_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_zero
+SHARK_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_shark
+
# Build variation of hotspot
$(C1_VM_TARGETS):
$(CD) $(GAMMADIR)/make; \
- $(MAKE) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
+ $(MAKE) BUILD_DIR=$(C1_DIR) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
$(C2_VM_TARGETS):
$(CD) $(GAMMADIR)/make; \
- $(MAKE) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
+ $(MAKE) BUILD_DIR=$(C2_DIR) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
$(ZERO_VM_TARGETS):
$(CD) $(GAMMADIR)/make; \
- $(MAKE) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ \
- generic_buildzero $(ALT_OUT)
+ $(MAKE) BUILD_DIR=$(ZERO_DIR) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ generic_buildzero $(ALT_OUT)
$(SHARK_VM_TARGETS):
$(CD) $(GAMMADIR)/make; \
- $(MAKE) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ \
- generic_buildshark $(ALT_OUT)
+ $(MAKE) BUILD_DIR=$(SHARK_DIR) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ generic_buildshark $(ALT_OUT)
$(MINIMAL1_VM_TARGETS):
$(CD) $(GAMMADIR)/make; \
- $(MAKE) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ \
- generic_buildminimal1 $(ALT_OUT)
+ $(MAKE) BUILD_DIR=$(MINIMAL1_DIR) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ generic_buildminimal1 $(ALT_OUT)
+
+# Install hotspot script in build directory
+HOTSPOT_SCRIPT=$(BUILD_DIR)/$(BUILD_FLAVOR)/hotspot
+$(HOTSPOT_SCRIPT): $(GAMMADIR)/make/hotspot.script
+ $(QUIETLY) $(MKDIR) -p $(BUILD_DIR)/$(BUILD_FLAVOR)
+ $(QUIETLY) cat $< | sed -e 's|@@LIBARCH@@|$(LIBARCH)|g' | sed -e 's|@@JDK_IMPORT_PATH@@|$(JDK_IMPORT_PATH)|g' > $@
+ $(QUIETLY) chmod +x $@
# Build compiler1 (client) rule, different for platforms
-generic_build1:
+generic_build1: $(HOTSPOT_SCRIPT)
$(MKDIR) -p $(OUTPUTDIR)
ifeq ($(OSNAME),windows)
ifeq ($(ARCH_DATA_MODEL), 32)
@@ -201,7 +212,7 @@ else
endif
# Build compiler2 (server) rule, different for platforms
-generic_build2:
+generic_build2: $(HOTSPOT_SCRIPT)
$(MKDIR) -p $(OUTPUTDIR)
ifeq ($(OSNAME),windows)
$(CD) $(OUTPUTDIR); \
@@ -217,19 +228,19 @@ else
$(MAKE_ARGS) $(VM_TARGET)
endif
-generic_buildzero:
+generic_buildzero: $(HOTSPOT_SCRIPT)
$(MKDIR) -p $(OUTPUTDIR)
$(CD) $(OUTPUTDIR); \
$(MAKE) -f $(ABS_OS_MAKEFILE) \
$(MAKE_ARGS) $(VM_TARGET)
-generic_buildshark:
+generic_buildshark: $(HOTSPOT_SCRIPT)
$(MKDIR) -p $(OUTPUTDIR)
$(CD) $(OUTPUTDIR); \
$(MAKE) -f $(ABS_OS_MAKEFILE) \
$(MAKE_ARGS) $(VM_TARGET)
-generic_buildminimal1:
+generic_buildminimal1: $(HOTSPOT_SCRIPT)
ifeq ($(JVM_VARIANT_MINIMAL1),true)
$(MKDIR) -p $(OUTPUTDIR)
ifeq ($(ARCH_DATA_MODEL), 32)
@@ -252,224 +263,210 @@ endif
# Export file rule
generic_export: $(EXPORT_LIST)
+
export_product:
- $(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%=%) generic_export
export_fastdebug:
- $(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
- EXPORT_SUBDIR=/$(@:export_%=%) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
export_debug:
- $(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
- EXPORT_SUBDIR=/$(@:export_%=%) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
export_optimized:
- $(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
- EXPORT_SUBDIR=/$(@:export_%=%) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
+
export_product_jdk::
- $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
- VM_SUBDIR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
export_optimized_jdk::
- $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
- VM_SUBDIR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
export_fastdebug_jdk::
- $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
- VM_SUBDIR=$(@:export_%_jdk=%) \
- ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
export_debug_jdk::
- $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) VM_SUBDIR=$(@:export_%_jdk=%) \
- ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) \
- generic_export
+ $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
# Export file copy rules
XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt
-DOCS_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_docs
-C1_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1/$(VM_SUBDIR)
-C2_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2/$(VM_SUBDIR)
-MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1/$(VM_SUBDIR)
-ZERO_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_zero/$(VM_SUBDIR)
-SHARK_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_shark/$(VM_SUBDIR)
+DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs
+C1_BUILD_DIR =$(C1_DIR)/$(BUILD_FLAVOR)
+C2_BUILD_DIR =$(C2_DIR)/$(BUILD_FLAVOR)
+MINIMAL1_BUILD_DIR=$(MINIMAL1_DIR)/$(BUILD_FLAVOR)
+ZERO_BUILD_DIR =$(ZERO_DIR)/$(BUILD_FLAVOR)
+SHARK_BUILD_DIR =$(SHARK_DIR)/$(BUILD_FLAVOR)
# Server (C2)
ifeq ($(JVM_VARIANT_SERVER), true)
# Common
-$(EXPORT_SERVER_DIR)/%.diz: $(C2_DIR)/%.diz
+$(EXPORT_SERVER_DIR)/%.diz: $(C2_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_LIB_DIR)/%.jar: $(C2_DIR)/../generated/%.jar
+$(EXPORT_LIB_DIR)/%.jar: $(C2_BUILD_DIR)/../generated/%.jar
$(install-file)
-$(EXPORT_INCLUDE_DIR)/%: $(C2_DIR)/../generated/jvmtifiles/%
+$(EXPORT_INCLUDE_DIR)/%: $(C2_BUILD_DIR)/../generated/jvmtifiles/%
$(install-file)
# Windows
-$(EXPORT_SERVER_DIR)/%.dll: $(C2_DIR)/%.dll
+$(EXPORT_SERVER_DIR)/%.dll: $(C2_BUILD_DIR)/%.dll
$(install-file)
-$(EXPORT_SERVER_DIR)/%.pdb: $(C2_DIR)/%.pdb
+$(EXPORT_SERVER_DIR)/%.pdb: $(C2_BUILD_DIR)/%.pdb
$(install-file)
-$(EXPORT_SERVER_DIR)/%.map: $(C2_DIR)/%.map
+$(EXPORT_SERVER_DIR)/%.map: $(C2_BUILD_DIR)/%.map
$(install-file)
-$(EXPORT_LIB_DIR)/%.lib: $(C2_DIR)/%.lib
+$(EXPORT_LIB_DIR)/%.lib: $(C2_BUILD_DIR)/%.lib
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.diz: $(C2_DIR)/%.diz
+$(EXPORT_JRE_BIN_DIR)/%.diz: $(C2_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.dll: $(C2_DIR)/%.dll
+$(EXPORT_JRE_BIN_DIR)/%.dll: $(C2_BUILD_DIR)/%.dll
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.pdb: $(C2_DIR)/%.pdb
+$(EXPORT_JRE_BIN_DIR)/%.pdb: $(C2_BUILD_DIR)/%.pdb
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.map: $(C2_DIR)/%.map
+$(EXPORT_JRE_BIN_DIR)/%.map: $(C2_BUILD_DIR)/%.map
$(install-file)
# Unix
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(C2_DIR)/%.debuginfo
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(C2_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo: $(C2_DIR)/%.debuginfo
+$(EXPORT_SERVER_DIR)/%.debuginfo: $(C2_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.debuginfo: $(C2_DIR)/%.debuginfo
+$(EXPORT_SERVER_DIR)/64/%.debuginfo: $(C2_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(C2_DIR)/%.diz
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(C2_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.diz: $(C2_DIR)/%.diz
+$(EXPORT_SERVER_DIR)/64/%.diz: $(C2_BUILD_DIR)/%.diz
$(install-file)
endif
# Client (C1)
ifeq ($(JVM_VARIANT_CLIENT), true)
# Common
-$(EXPORT_CLIENT_DIR)/%.diz: $(C1_DIR)/%.diz
+$(EXPORT_CLIENT_DIR)/%.diz: $(C1_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_LIB_DIR)/%.jar: $(C1_DIR)/../generated/%.jar
+$(EXPORT_LIB_DIR)/%.jar: $(C1_BUILD_DIR)/../generated/%.jar
$(install-file)
-$(EXPORT_INCLUDE_DIR)/%: $(C1_DIR)/../generated/jvmtifiles/%
+$(EXPORT_INCLUDE_DIR)/%: $(C1_BUILD_DIR)/../generated/jvmtifiles/%
$(install-file)
# Windows
-$(EXPORT_CLIENT_DIR)/%.dll: $(C1_DIR)/%.dll
+$(EXPORT_CLIENT_DIR)/%.dll: $(C1_BUILD_DIR)/%.dll
$(install-file)
-$(EXPORT_CLIENT_DIR)/%.pdb: $(C1_DIR)/%.pdb
+$(EXPORT_CLIENT_DIR)/%.pdb: $(C1_BUILD_DIR)/%.pdb
$(install-file)
-$(EXPORT_CLIENT_DIR)/%.map: $(C1_DIR)/%.map
+$(EXPORT_CLIENT_DIR)/%.map: $(C1_BUILD_DIR)/%.map
$(install-file)
-$(EXPORT_LIB_DIR)/%.lib: $(C1_DIR)/%.lib
+$(EXPORT_LIB_DIR)/%.lib: $(C1_BUILD_DIR)/%.lib
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.diz: $(C1_DIR)/%.diz
+$(EXPORT_JRE_BIN_DIR)/%.diz: $(C1_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.dll: $(C1_DIR)/%.dll
+$(EXPORT_JRE_BIN_DIR)/%.dll: $(C1_BUILD_DIR)/%.dll
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.pdb: $(C1_DIR)/%.pdb
+$(EXPORT_JRE_BIN_DIR)/%.pdb: $(C1_BUILD_DIR)/%.pdb
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.map: $(C1_DIR)/%.map
+$(EXPORT_JRE_BIN_DIR)/%.map: $(C1_BUILD_DIR)/%.map
$(install-file)
# Unix
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(C1_DIR)/%.debuginfo
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(C1_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_CLIENT_DIR)/%.debuginfo: $(C1_DIR)/%.debuginfo
+$(EXPORT_CLIENT_DIR)/%.debuginfo: $(C1_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.debuginfo: $(C1_DIR)/%.debuginfo
+$(EXPORT_CLIENT_DIR)/64/%.debuginfo: $(C1_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(C1_DIR)/%.diz
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(C1_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.diz: $(C1_DIR)/%.diz
+$(EXPORT_CLIENT_DIR)/64/%.diz: $(C1_BUILD_DIR)/%.diz
$(install-file)
endif
# Minimal1
ifeq ($(JVM_VARIANT_MINIMAL1), true)
# Common
-$(EXPORT_MINIMAL_DIR)/%.diz: $(MINIMAL1_DIR)/%.diz
+$(EXPORT_MINIMAL_DIR)/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_LIB_DIR)/%.jar: $(MINIMAL1_DIR)/../generated/%.jar
+$(EXPORT_LIB_DIR)/%.jar: $(MINIMAL1_BUILD_DIR)/../generated/%.jar
$(install-file)
-$(EXPORT_INCLUDE_DIR)/%: $(MINIMAL1_DIR)/../generated/jvmtifiles/%
+$(EXPORT_INCLUDE_DIR)/%: $(MINIMAL1_BUILD_DIR)/../generated/jvmtifiles/%
$(install-file)
# Windows
-$(EXPORT_MINIMAL_DIR)/%.dll: $(MINIMAL1_DIR)/%.dll
+$(EXPORT_MINIMAL_DIR)/%.dll: $(MINIMAL1_BUILD_DIR)/%.dll
$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.pdb: $(MINIMAL1_DIR)/%.pdb
+$(EXPORT_MINIMAL_DIR)/%.pdb: $(MINIMAL1_BUILD_DIR)/%.pdb
$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.map: $(MINIMAL1_DIR)/%.map
+$(EXPORT_MINIMAL_DIR)/%.map: $(MINIMAL1_BUILD_DIR)/%.map
$(install-file)
-$(EXPORT_LIB_DIR)/%.lib: $(MINIMAL1_DIR)/%.lib
+$(EXPORT_LIB_DIR)/%.lib: $(MINIMAL1_BUILD_DIR)/%.lib
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.diz: $(MINIMAL1_DIR)/%.diz
+$(EXPORT_JRE_BIN_DIR)/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.dll: $(MINIMAL1_DIR)/%.dll
+$(EXPORT_JRE_BIN_DIR)/%.dll: $(MINIMAL1_BUILD_DIR)/%.dll
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.pdb: $(MINIMAL1_DIR)/%.pdb
+$(EXPORT_JRE_BIN_DIR)/%.pdb: $(MINIMAL1_BUILD_DIR)/%.pdb
$(install-file)
-$(EXPORT_JRE_BIN_DIR)/%.map: $(MINIMAL1_DIR)/%.map
+$(EXPORT_JRE_BIN_DIR)/%.map: $(MINIMAL1_BUILD_DIR)/%.map
$(install-file)
# Unix
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX): $(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX): $(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(MINIMAL1_DIR)/%.debuginfo
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(MINIMAL1_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_MINIMAL_DIR)/%.debuginfo: $(MINIMAL1_DIR)/%.debuginfo
+$(EXPORT_MINIMAL_DIR)/%.debuginfo: $(MINIMAL1_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_MINIMAL_DIR)/64/%.debuginfo: $(MINIMAL1_DIR)/%.debuginfo
+$(EXPORT_MINIMAL_DIR)/64/%.debuginfo: $(MINIMAL1_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(MINIMAL1_DIR)/%.diz
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_MINIMAL_DIR)/64/%.diz: $(MINIMAL1_DIR)/%.diz
+$(EXPORT_MINIMAL_DIR)/64/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz
$(install-file)
endif
# Zero
ifeq ($(JVM_VARIANT_ZERO), true)
# Common
-$(EXPORT_LIB_DIR)/%.jar: $(ZERO_DIR)/../generated/%.jar
+$(EXPORT_LIB_DIR)/%.jar: $(ZERO_BUILD_DIR)/../generated/%.jar
$(install-file)
-$(EXPORT_INCLUDE_DIR)/%: $(ZERO_DIR)/../generated/jvmtifiles/%
+$(EXPORT_INCLUDE_DIR)/%: $(ZERO_BUILD_DIR)/../generated/jvmtifiles/%
$(install-file)
# Unix
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(ZERO_DIR)/%.debuginfo
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(ZERO_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(ZERO_DIR)/%.diz
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(ZERO_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo: $(ZERO_DIR)/%.debuginfo
+$(EXPORT_SERVER_DIR)/%.debuginfo: $(ZERO_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_SERVER_DIR)/%.diz: $(ZERO_DIR)/%.diz
+$(EXPORT_SERVER_DIR)/%.diz: $(ZERO_BUILD_DIR)/%.diz
$(install-file)
endif
# Shark
ifeq ($(JVM_VARIANT_ZEROSHARK), true)
# Common
-$(EXPORT_LIB_DIR)/%.jar: $(SHARK_DIR)/../generated/%.jar
+$(EXPORT_LIB_DIR)/%.jar: $(SHARK_BUILD_DIR)/../generated/%.jar
$(install-file)
-$(EXPORT_INCLUDE_DIR)/%: $(SHARK_DIR)/../generated/jvmtifiles/%
+$(EXPORT_INCLUDE_DIR)/%: $(SHARK_BUILD_DIR)/../generated/jvmtifiles/%
$(install-file)
# Unix
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo): $(SHARK_DIR)/%.debuginfo
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo): $(SHARK_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(SHARK_DIR)/%.diz
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(SHARK_BUILD_DIR)/%.diz
$(install-file)
-$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file)
-$(EXPORT_SERVER_DIR)/%.debuginfo: $(SHARK_DIR)/%.debuginfo
+$(EXPORT_SERVER_DIR)/%.debuginfo: $(SHARK_BUILD_DIR)/%.debuginfo
$(install-file)
-$(EXPORT_SERVER_DIR)/%.diz: $(SHARK_DIR)/%.diz
+$(EXPORT_SERVER_DIR)/%.diz: $(SHARK_BUILD_DIR)/%.diz
$(install-file)
endif
diff --git a/hotspot/make/bsd/makefiles/buildtree.make b/hotspot/make/bsd/makefiles/buildtree.make
index 9d0a2174c54..16a0f9a64ff 100644
--- a/hotspot/make/bsd/makefiles/buildtree.make
+++ b/hotspot/make/bsd/makefiles/buildtree.make
@@ -49,7 +49,6 @@
# adlc.make -
# jvmti.make - generate JVMTI bindings from the spec (JSR-163)
# sa.make - generate SA jar file and natives
-# env.[ck]sh - environment settings
#
# The makefiles are split this way so that "make foo" will run faster by not
# having to read the dependency files for the vm.
@@ -129,9 +128,7 @@ SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
# dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make \
- jvmti.make sa.make dtrace.make \
- env.sh env.csh jdkpath.sh
+BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make dtrace.make
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
@@ -354,33 +351,6 @@ dtrace.make: $(BUILDTREE_MAKE)
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
) > $@
-env.sh: $(BUILDTREE_MAKE)
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- { echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
- { \
- echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
- } | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
- echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
- echo "export JAVA_HOME CLASSPATH HOTSPOT_BUILD_USER"; \
- ) > $@
-
-env.csh: env.sh
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- { echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
- sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
- ) > $@
-
-jdkpath.sh: $(BUILDTREE_MAKE)
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- echo "JDK=${JAVA_HOME}"; \
- ) > $@
-
FORCE:
.PHONY: all FORCE
diff --git a/hotspot/make/bsd/makefiles/launcher.make b/hotspot/make/bsd/makefiles/launcher.make
deleted file mode 100644
index 588bf9aaebf..00000000000
--- a/hotspot/make/bsd/makefiles/launcher.make
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# Copyright (c) 2005, 2012, 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.
-#
-#
-
-# Rules to build gamma launcher, used by vm.make
-
-
-LAUNCHER_SCRIPT = hotspot
-LAUNCHER = gamma
-
-LAUNCHERDIR := $(GAMMADIR)/src/os/posix/launcher
-LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
-LAUNCHERFLAGS := $(ARCHFLAG) \
- -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
- -I$(LAUNCHERDIR_SHARE) \
- -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
- -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
- -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
- -DARCH=\"$(LIBARCH)\" \
- -DGAMMA \
- -DLAUNCHER_TYPE=\"gamma\" \
- -DLINK_INTO_$(LINK_INTO) \
- $(TARGET_DEFINES)
-# Give the launcher task_for_pid() privileges so that it can be used to run JStack, JInfo, et al.
-LFLAGS_LAUNCHER += -sectcreate __TEXT __info_plist $(GAMMADIR)/src/os/bsd/launcher/Info-privileged.plist
-
-ifeq ($(LINK_INTO),AOUT)
- LAUNCHER.o = launcher.o $(JVM_OBJ_FILES)
- LAUNCHER_MAPFILE = mapfile_reorder
- LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
- LFLAGS_LAUNCHER += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
- LIBS_LAUNCHER += $(STATIC_STDCXX) $(LIBS)
-else
- LAUNCHER.o = launcher.o
- LFLAGS_LAUNCHER += -L`pwd`
-
- # The gamma launcher runs the JDK from $JAVA_HOME, overriding the JVM with a
- # freshly built JVM at ./libjvm.{so|dylib}. This is accomplished by setting
- # the library searchpath using ({DY}LD_LIBRARY_PATH) to find the local JVM
- # first. Gamma dlopen()s libjava from $JAVA_HOME/jre/lib{/$arch}, which is
- # statically linked with CoreFoundation framework libs. Unfortunately, gamma's
- # unique searchpath results in some unresolved symbols in the framework
- # libraries, because JDK libraries are inadvertently discovered first on the
- # searchpath, e.g. libjpeg. On Mac OS X, filenames are case *insensitive*.
- # So, the actual filename collision is libjpeg.dylib and libJPEG.dylib.
- # To resolve this, gamma needs to also statically link with the CoreFoundation
- # framework libraries.
-
- ifeq ($(OS_VENDOR),Darwin)
- LFLAGS_LAUNCHER += -framework CoreFoundation
- endif
-
- LIBS_LAUNCHER += -l$(JVM) $(LIBS)
-endif
-
-LINK_LAUNCHER = $(LINK.CC)
-
-LINK_LAUNCHER/PRE_HOOK = $(LINK_LIB.CXX/PRE_HOOK)
-LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
-
-LAUNCHER_OUT = launcher
-
-SUFFIXES += .d
-
-SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
-SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
-
-OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
-
-DEPFILES := $(patsubst %.o,%.d,$(OBJS))
--include $(DEPFILES)
-
-$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
- $(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
- $(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
-
-$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
- $(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
- $(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
-
-$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
- $(QUIETLY) echo Linking launcher...
- $(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
- $(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
- $(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
- # Sign the launcher with the development certificate (if present) so that it can be used
- # to run JStack, JInfo, et al.
- $(QUIETLY) -codesign -s openjdk_codesign $@
-
-$(LAUNCHER): $(LAUNCHER_SCRIPT)
-
-$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
- $(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
- $(QUIETLY) chmod +x $@
-
diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make
index b9528e101ee..974a568efcb 100644
--- a/hotspot/make/bsd/makefiles/vm.make
+++ b/hotspot/make/bsd/makefiles/vm.make
@@ -328,9 +328,6 @@ install_jvm: $(LIBJVM)
#----------------------------------------------------------------------
# Other files
-# Gamma launcher
-include $(MAKEFILES_DIR)/launcher.make
-
# Signal interposition library
include $(MAKEFILES_DIR)/jsig.make
diff --git a/hotspot/src/os/posix/launcher/launcher.script b/hotspot/make/hotspot.script
similarity index 89%
rename from hotspot/src/os/posix/launcher/launcher.script
rename to hotspot/make/hotspot.script
index e8d4281808a..c6259ba2eee 100644
--- a/hotspot/src/os/posix/launcher/launcher.script
+++ b/hotspot/make/hotspot.script
@@ -72,6 +72,7 @@ EMACS=emacs
REL_MYDIR=`dirname $0`
MYDIR=`cd $REL_MYDIR && pwd`
+#
# Look whether the user wants to run inside gdb
case "$1" in
-gdb)
@@ -95,16 +96,14 @@ case "$1" in
;;
esac
-JDK=
-if [ "${ALT_JAVA_HOME}" = "" ]; then
- . ${MYDIR}/jdkpath.sh
+if [ "${ALT_JAVA_HOME}" != "" ]; then
+ JDK=${ALT_JAVA_HOME%%/jre}
else
- JDK=${ALT_JAVA_HOME%%/jre};
+ JDK=@@JDK_IMPORT_PATH@@
fi
if [ "${JDK}" = "" ]; then
- echo Failed to find JDK. ALT_JAVA_HOME is not set or ./jdkpath.sh is empty or not found.
- exit 1
+ echo "Failed to find JDK. Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
fi
# We will set the LD_LIBRARY_PATH as follows:
@@ -142,12 +141,12 @@ else
export LD_LIBRARY_PATH
fi
-JPARMS="$@ $JAVA_ARGS";
+JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS";
-# Locate the gamma development launcher
-LAUNCHER=${MYDIR}/gamma
+# Locate the java launcher
+LAUNCHER=$JDK/bin/java
if [ ! -x $LAUNCHER ] ; then
- echo Error: Cannot find the gamma development launcher \"$LAUNCHER\"
+ echo Error: Cannot find the java launcher \"$LAUNCHER\"
exit 1
fi
@@ -166,9 +165,10 @@ set args $JPARMS
file $LAUNCHER
directory $GDBSRCDIR
# Get us to a point where we can set breakpoints in libjvm.so
-break InitializeJVM
+set breakpoint pending on
+break JNI_CreateJavaVM
run
-# Stop in InitializeJVM
+# Stop in JNI_CreateJavaVM
delete 1
# We can now set breakpoints wherever we like
EOF
@@ -199,7 +199,7 @@ case "$MODE" in
rm -f $GDBSCR
;;
dbx)
- $DBX -s $HOME/.dbxrc $LAUNCHER $JPARMS
+ $DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER
;;
valgrind)
echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make
index 0b7c12001b3..3b715773554 100644
--- a/hotspot/make/linux/makefiles/buildtree.make
+++ b/hotspot/make/linux/makefiles/buildtree.make
@@ -49,7 +49,6 @@
# adlc.make -
# jvmti.make - generate JVMTI bindings from the spec (JSR-163)
# sa.make - generate SA jar file and natives
-# env.[ck]sh - environment settings
#
# The makefiles are split this way so that "make foo" will run faster by not
# having to read the dependency files for the vm.
@@ -123,8 +122,7 @@ SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
# For dependencies and recursive makes.
BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
- env.sh env.csh jdkpath.sh
+BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
@@ -349,33 +347,6 @@ sa.make: $(BUILDTREE_MAKE)
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
) > $@
-env.sh: $(BUILDTREE_MAKE)
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- { echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
- { \
- echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
- } | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
- echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
- echo "export JAVA_HOME CLASSPATH HOTSPOT_BUILD_USER"; \
- ) > $@
-
-env.csh: env.sh
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- { echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
- sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
- ) > $@
-
-jdkpath.sh: $(BUILDTREE_MAKE)
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- echo "JDK=${JAVA_HOME}"; \
- ) > $@
-
FORCE:
.PHONY: all FORCE
diff --git a/hotspot/make/linux/makefiles/launcher.make b/hotspot/make/linux/makefiles/launcher.make
deleted file mode 100644
index 23f3edad41a..00000000000
--- a/hotspot/make/linux/makefiles/launcher.make
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# Copyright (c) 2005, 2012, 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.
-#
-#
-
-# Rules to build gamma launcher, used by vm.make
-
-
-LAUNCHER_SCRIPT = hotspot
-LAUNCHER = gamma
-
-LAUNCHERDIR := $(GAMMADIR)/src/os/posix/launcher
-LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
-LAUNCHERFLAGS := $(ARCHFLAG) \
- -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
- -I$(LAUNCHERDIR_SHARE) \
- -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
- -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
- -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
- -DARCH=\"$(LIBARCH)\" \
- -DGAMMA \
- -DLAUNCHER_TYPE=\"gamma\" \
- -DLINK_INTO_$(LINK_INTO) \
- $(TARGET_DEFINES)
-
-ifeq ($(LINK_INTO),AOUT)
- LAUNCHER.o = launcher.o $(JVM_OBJ_FILES)
- LAUNCHER_MAPFILE = mapfile_reorder
- LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
- LFLAGS_LAUNCHER += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
- LIBS_LAUNCHER += $(STATIC_STDCXX) $(LIBS)
-else
- LAUNCHER.o = launcher.o
- LFLAGS_LAUNCHER += -L `pwd`
- LIBS_LAUNCHER += -l$(JVM) $(LIBS)
-endif
-
-LINK_LAUNCHER = $(LINK.CC)
-
-LINK_LAUNCHER/PRE_HOOK = $(LINK_LIB.CXX/PRE_HOOK)
-LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
-
-LAUNCHER_OUT = launcher
-
-SUFFIXES += .d
-
-SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
-SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
-
-OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
-
-DEPFILES := $(patsubst %.o,%.d,$(OBJS))
--include $(DEPFILES)
-
-$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
- $(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
- $(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
-
-$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
- $(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
- $(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
-
-$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
- $(QUIETLY) echo Linking launcher...
- $(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
- $(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
- $(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
-
-$(LAUNCHER): $(LAUNCHER_SCRIPT)
-
-$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
- $(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
- $(QUIETLY) chmod +x $@
-
diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make
index af060f8af0b..79a926a8c4f 100644
--- a/hotspot/make/linux/makefiles/vm.make
+++ b/hotspot/make/linux/makefiles/vm.make
@@ -372,9 +372,6 @@ install_jvm: $(LIBJVM)
#----------------------------------------------------------------------
# Other files
-# Gamma launcher
-include $(MAKEFILES_DIR)/launcher.make
-
# Signal interposition library
include $(MAKEFILES_DIR)/jsig.make
diff --git a/hotspot/make/solaris/makefiles/buildtree.make b/hotspot/make/solaris/makefiles/buildtree.make
index 989470f293f..5827c4ff7d9 100644
--- a/hotspot/make/solaris/makefiles/buildtree.make
+++ b/hotspot/make/solaris/makefiles/buildtree.make
@@ -49,7 +49,6 @@
# adlc.make -
# jvmti.make - generate JVMTI bindings from the spec (JSR-163)
# sa.make - generate SA jar file and natives
-# env.[ck]sh - environment settings
#
# The makefiles are split this way so that "make foo" will run faster by not
# having to read the dependency files for the vm.
@@ -116,8 +115,7 @@ SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
# For dependencies and recursive makes.
BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
-BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
- env.sh env.csh jdkpath.sh
+BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
@@ -339,33 +337,6 @@ sa.make: $(BUILDTREE_MAKE)
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
) > $@
-env.sh: $(BUILDTREE_MAKE)
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- { echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
- { \
- echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
- } | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
- echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
- echo "export JAVA_HOME LD_LIBRARY_PATH CLASSPATH HOTSPOT_BUILD_USER"; \
- ) > $@
-
-env.csh: env.sh
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- { echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
- sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
- ) > $@
-
-jdkpath.sh: $(BUILDTREE_MAKE)
- @echo Creating $@ ...
- $(QUIETLY) ( \
- $(BUILDTREE_COMMENT); \
- echo "JDK=${JAVA_HOME}"; \
- ) > $@
-
FORCE:
.PHONY: all FORCE
diff --git a/hotspot/make/solaris/makefiles/launcher.make b/hotspot/make/solaris/makefiles/launcher.make
deleted file mode 100644
index 090ff5ea7a6..00000000000
--- a/hotspot/make/solaris/makefiles/launcher.make
+++ /dev/null
@@ -1,108 +0,0 @@
-#
-# Copyright (c) 2005, 2012, 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.
-#
-#
-
-# Rules to build gamma launcher, used by vm.make
-
-LAUNCHER_SCRIPT = hotspot
-LAUNCHER = gamma
-
-LAUNCHERDIR = $(GAMMADIR)/src/os/posix/launcher
-LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
-LAUNCHERFLAGS = $(ARCHFLAG) \
- -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
- -I$(LAUNCHERDIR_SHARE) \
- -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
- -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
- -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
- -DARCH=\"$(LIBARCH)\" \
- -DGAMMA \
- -DLAUNCHER_TYPE=\"gamma\" \
- -DLINK_INTO_$(LINK_INTO) \
- $(TARGET_DEFINES)
-
-ifeq ($(LINK_INTO),AOUT)
- LAUNCHER.o = launcher.o $(JVM_OBJ_FILES)
- LAUNCHER_MAPFILE = mapfile_extended
- LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
- LIBS_LAUNCHER += $(LIBS)
-else
- LAUNCHER.o = launcher.o
- LFLAGS_LAUNCHER += -L `pwd`
- LIBS_LAUNCHER += -l$(JVM) $(LIBS)
-endif
-
-LINK_LAUNCHER = $(LINK.CXX)
-
-LINK_LAUNCHER/PRE_HOOK = $(LINK_LIB.CXX/PRE_HOOK)
-LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-# Enable the following LAUNCHERFLAGS addition if you need to compare the
-# built ELF objects.
-#
-# The -g option makes static data global and the "-W0,-noglobal"
-# option tells the compiler to not globalize static data using a unique
-# globalization prefix. Instead force the use of a static globalization
-# prefix based on the source filepath so the objects from two identical
-# compilations are the same.
-#
-# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
-# seem to work. I got "-W0,-noglobal" from Kelly and that works.
-#LAUNCHERFLAGS += -W0,-noglobal
-endif # Platform_compiler == sparcWorks
-
-LAUNCHER_OUT = launcher
-
-SUFFIXES += .d
-
-SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
-SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
-
-OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
-
-DEPFILES := $(patsubst %.o,%.d,$(OBJS))
--include $(DEPFILES)
-
-$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
- $(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
- $(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
-
-$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
- $(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
- $(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
-
-$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
-ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
- $(QUIETLY) echo Linking launcher...
- $(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
- $(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
- $(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
-endif # filter -sbfast -xsbfast
-
-$(LAUNCHER): $(LAUNCHER_SCRIPT)
-
-$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
- $(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
- $(QUIETLY) chmod +x $@
-
diff --git a/hotspot/make/solaris/makefiles/vm.make b/hotspot/make/solaris/makefiles/vm.make
index 62146d77f03..855f7f18861 100644
--- a/hotspot/make/solaris/makefiles/vm.make
+++ b/hotspot/make/solaris/makefiles/vm.make
@@ -338,9 +338,6 @@ install_jvm: $(LIBJVM)
#----------------------------------------------------------------------
# Other files
-# Gamma launcher
-include $(MAKEFILES_DIR)/launcher.make
-
# Signal interposition library
include $(MAKEFILES_DIR)/jsig.make
diff --git a/hotspot/make/windows/makefiles/debug.make b/hotspot/make/windows/makefiles/debug.make
index c19f1757b69..2fca2182841 100644
--- a/hotspot/make/windows/makefiles/debug.make
+++ b/hotspot/make/windows/makefiles/debug.make
@@ -33,7 +33,7 @@ GENERATED=../generated
BUILD_PCH_FILE=_build_pch_file.obj
!endif
-default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
+default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
!include ../local.make
!include compile.make
@@ -71,4 +71,3 @@ $(AOUT): $(Res_Files) $(Obj_Files) vm.def
!include $(WorkSpace)/make/windows/makefiles/shared.make
!include $(WorkSpace)/make/windows/makefiles/sa.make
-!include $(WorkSpace)/make/windows/makefiles/launcher.make
diff --git a/hotspot/make/windows/makefiles/fastdebug.make b/hotspot/make/windows/makefiles/fastdebug.make
index 0fc2329dfd9..cde98f214ea 100644
--- a/hotspot/make/windows/makefiles/fastdebug.make
+++ b/hotspot/make/windows/makefiles/fastdebug.make
@@ -33,7 +33,7 @@ GENERATED=../generated
BUILD_PCH_FILE=_build_pch_file.obj
!endif
-default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
+default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
!include ../local.make
!include compile.make
@@ -70,4 +70,3 @@ $(AOUT): $(Res_Files) $(Obj_Files) vm.def
!include $(WorkSpace)/make/windows/makefiles/shared.make
!include $(WorkSpace)/make/windows/makefiles/sa.make
-!include $(WorkSpace)/make/windows/makefiles/launcher.make
diff --git a/hotspot/make/windows/makefiles/launcher.make b/hotspot/make/windows/makefiles/launcher.make
deleted file mode 100644
index 10ad009eef9..00000000000
--- a/hotspot/make/windows/makefiles/launcher.make
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# Copyright (c) 2010, 2012, 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.
-#
-#
-
-
-LAUNCHER_FLAGS=$(CXX_FLAGS) $(ARCHFLAG) \
- /D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
- /D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
- /D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
- /D GAMMA \
- /D LAUNCHER_TYPE=\"gamma\" \
- /D _CRT_SECURE_NO_WARNINGS \
- /D _CRT_SECURE_NO_DEPRECATE \
- /D LINK_INTO_LIBJVM \
- /I $(WorkSpace)\src\os\windows\launcher \
- /I $(WorkSpace)\src\share\tools\launcher \
- /I $(WorkSpace)\src\share\vm\prims \
- /I $(WorkSpace)\src\share\vm \
- /I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \
- /I $(WorkSpace)\src\os\windows\vm
-
-LD_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console
-
-!if "$(COMPILER_NAME)" == "VS2005"
-# This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib
-# on the link command line, otherwise we get missing __security_check_cookie
-# externals at link time. Even with /GS-, you need bufferoverflowU.lib.
-BUFFEROVERFLOWLIB = bufferoverflowU.lib
-LD_FLAGS = $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
-!endif
-
-!if "$(COMPILER_NAME)" == "VS2010" && "$(BUILDARCH)" == "i486"
-LD_FLAGS = /SAFESEH $(LD_FLAGS)
-!endif
-
-LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher
-LAUNCHERDIR_SHARE = $(WorkSpace)/src/share/tools/launcher
-
-OUTDIR = launcher
-
-{$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj:
- -mkdir $(OUTDIR) 2>NUL >NUL
- $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
-
-{$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj:
- -mkdir $(OUTDIR) 2>NUL >NUL
- $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
-
-$(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h
-
-launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj
- echo $(JAVA_HOME) > jdkpath.txt
- $(LD) $(LD_FLAGS) /out:hotspot.exe $**
diff --git a/hotspot/make/windows/makefiles/product.make b/hotspot/make/windows/makefiles/product.make
index f166f7377bf..407484cd46e 100644
--- a/hotspot/make/windows/makefiles/product.make
+++ b/hotspot/make/windows/makefiles/product.make
@@ -32,7 +32,7 @@ GENERATED=../generated
BUILD_PCH_FILE=_build_pch_file.obj
!endif
-default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
+default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
!include ../local.make
!include compile.make
@@ -73,4 +73,3 @@ $(AOUT): $(Res_Files) $(Obj_Files) vm.def
!include $(WorkSpace)/make/windows/makefiles/shared.make
!include $(WorkSpace)/make/windows/makefiles/sa.make
-!include $(WorkSpace)/make/windows/makefiles/launcher.make
diff --git a/hotspot/make/windows/makefiles/projectcreator.make b/hotspot/make/windows/makefiles/projectcreator.make
index 68d098d0de3..f142852ed12 100644
--- a/hotspot/make/windows/makefiles/projectcreator.make
+++ b/hotspot/make/windows/makefiles/projectcreator.make
@@ -59,7 +59,6 @@ ProjectCreatorIncludesPRIVATE=\
-relativeSrcInclude src \
-absoluteSrcInclude $(HOTSPOTBUILDSPACE) \
-ignorePath $(HOTSPOTBUILDSPACE) \
- -ignorePath launcher \
-ignorePath share\vm\adlc \
-ignorePath share\vm\shark \
-ignorePath share\tools \
@@ -105,7 +104,6 @@ ProjectCreatorIDEOptions=\
-define ALIGN_STACK_FRAMES \
-define VM_LITTLE_ENDIAN \
-prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \
- -postbuild "" "Building hotspot.exe..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) nmake -f $(HOTSPOTWORKSPACE)\make\windows\projectfiles\common\Makefile LOCAL_MAKE=$(HOTSPOTBUILDSPACE)\%f\local.make JAVA_HOME=$(HOTSPOTJDKDIST) launcher" \
-ignoreFile jsig.c \
-ignoreFile jvmtiEnvRecommended.cpp \
-ignoreFile jvmtiEnvStub.cpp \
diff --git a/hotspot/make/windows/projectfiles/common/Makefile b/hotspot/make/windows/projectfiles/common/Makefile
index 125923e67b2..5556aae5149 100644
--- a/hotspot/make/windows/projectfiles/common/Makefile
+++ b/hotspot/make/windows/projectfiles/common/Makefile
@@ -65,7 +65,6 @@ JvmtiOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\jvmtifiles
!endif
HS_INTERNAL_NAME=jvm
-!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/launcher.make
default:: $(AdditionalTargets) $(JvmtiGeneratedFiles)
diff --git a/hotspot/src/os/posix/launcher/java_md.c b/hotspot/src/os/posix/launcher/java_md.c
deleted file mode 100644
index b5fc949813c..00000000000
--- a/hotspot/src/os/posix/launcher/java_md.c
+++ /dev/null
@@ -1,1936 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- *
- */
-
-
-#include "java.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#ifndef GAMMA
-#include "manifest_info.h"
-#include "version_comp.h"
-#endif
-
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
-#include
-#else
-#include
-#endif
-
-#ifdef __APPLE__
-#define JVM_DLL "libjvm.dylib"
-#define JAVA_DLL "libjava.dylib"
-#define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
-#else
-#define JVM_DLL "libjvm.so"
-#define JAVA_DLL "libjava.so"
-#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
-#endif
-
-#ifndef GAMMA /* launcher.make defines ARCH */
-/*
- * If a processor / os combination has the ability to run binaries of
- * two data models and cohabitation of jre/jdk bits with both data
- * models is supported, then DUAL_MODE is defined. When DUAL_MODE is
- * defined, the architecture names for the narrow and wide version of
- * the architecture are defined in LIBARCH64NAME and LIBARCH32NAME. Currently
- * only Solaris on sparc/sparcv9 and i586/amd64 is DUAL_MODE; linux
- * i586/amd64 could be defined as DUAL_MODE but that is not the
- * current policy.
- */
-
-#ifndef LIBARCHNAME
-# error "The macro LIBARCHNAME was not defined on the compile line"
-#endif
-
-#ifdef __sun
-# define DUAL_MODE
-# ifndef LIBARCH32NAME
-# error "The macro LIBARCH32NAME was not defined on the compile line"
-# endif
-# ifndef LIBARCH64NAME
-# error "The macro LIBARCH64NAME was not defined on the compile line"
-# endif
-# include
-# include
-# include
-#endif
-
-#endif /* ifndef GAMMA */
-
-/* pointer to environment */
-extern char **environ;
-
-#ifndef GAMMA
-/*
- * A collection of useful strings. One should think of these as #define
- * entries, but actual strings can be more efficient (with many compilers).
- */
-#ifdef __linux__
-static const char *system_dir = "/usr/java";
-static const char *user_dir = "/java";
-#else /* Solaris */
-static const char *system_dir = "/usr/jdk";
-static const char *user_dir = "/jdk";
-#endif
-
-#endif /* ifndef GAMMA */
-
-/*
- * Flowchart of launcher execs and options processing on unix
- *
- * The selection of the proper vm shared library to open depends on
- * several classes of command line options, including vm "flavor"
- * options (-client, -server) and the data model options, -d32 and
- * -d64, as well as a version specification which may have come from
- * the command line or from the manifest of an executable jar file.
- * The vm selection options are not passed to the running
- * virtual machine; they must be screened out by the launcher.
- *
- * The version specification (if any) is processed first by the
- * platform independent routine SelectVersion. This may result in
- * the exec of the specified launcher version.
- *
- * Typically, the launcher execs at least once to ensure a suitable
- * LD_LIBRARY_PATH is in effect for the process. The first exec
- * screens out all the data model options; leaving the choice of data
- * model implicit in the binary selected to run. However, in case no
- * exec is done, the data model options are screened out before the vm
- * is invoked.
- *
- * incoming argv ------------------------------
- * | |
- * \|/ |
- * CheckJVMType |
- * (removes -client, -server, etc.) |
- * \|/
- * CreateExecutionEnvironment
- * (removes -d32 and -d64,
- * determines desired data model,
- * sets up LD_LIBRARY_PATH,
- * and exec's)
- * |
- * --------------------------------------------
- * |
- * \|/
- * exec child 1 incoming argv -----------------
- * | |
- * \|/ |
- * CheckJVMType |
- * (removes -client, -server, etc.) |
- * | \|/
- * | CreateExecutionEnvironment
- * | (verifies desired data model
- * | is running and acceptable
- * | LD_LIBRARY_PATH;
- * | no-op in child)
- * |
- * \|/
- * TranslateDashJArgs...
- * (Prepare to pass args to vm)
- * |
- * |
- * |
- * \|/
- * ParseArguments
- * (ignores -d32 and -d64,
- * processes version options,
- * creates argument list for vm,
- * etc.)
- *
- */
-
-static char *SetExecname(char **argv);
-static char * GetExecname();
-static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
- char *jvmpath, jint jvmpathsize, char * arch);
-static jboolean GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative);
-
-#ifndef GAMMA
-const char *
-GetArch()
-{
- return LIBARCHNAME;
-}
-#endif /* ifndef GAMMA */
-
-void
-CreateExecutionEnvironment(int *_argcp,
- char ***_argvp,
- char jrepath[],
- jint so_jrepath,
- char jvmpath[],
- jint so_jvmpath,
- char **original_argv) {
- /*
- * First, determine if we are running the desired data model. If we
- * are running the desired data model, all the error messages
- * associated with calling GetJREPath, ReadKnownVMs, etc. should be
- * output. However, if we are not running the desired data model,
- * some of the errors should be suppressed since it is more
- * informative to issue an error message based on whether or not the
- * os/processor combination has dual mode capabilities.
- */
-
- char *execname = NULL;
- int original_argc = *_argcp;
- jboolean jvmpathExists;
-
- /* Compute the name of the executable */
- execname = SetExecname(*_argvp);
-
-#ifndef GAMMA
- /* Set the LD_LIBRARY_PATH environment variable, check data model
- flags, and exec process, if needed */
- {
- char *arch = (char *)GetArch(); /* like sparc or sparcv9 */
- char * jvmtype = NULL;
- int argc = *_argcp;
- char **argv = original_argv;
-
- char *runpath = NULL; /* existing effective LD_LIBRARY_PATH
- setting */
-
- int running = /* What data model is being ILP32 =>
- 32 bit vm; LP64 => 64 bit vm */
-#ifdef _LP64
- 64;
-#else
- 32;
-#endif
-
- int wanted = running; /* What data mode is being
- asked for? Current model is
- fine unless another model
- is asked for */
-
- char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
- char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
- char* lastslash = NULL;
-
- char** newenvp = NULL; /* current environment */
-
- char** newargv = NULL;
- int newargc = 0;
-#ifdef __sun
- char* dmpath = NULL; /* data model specific LD_LIBRARY_PATH,
- Solaris only */
-#endif
-
- /*
- * Starting in 1.5, all unix platforms accept the -d32 and -d64
- * options. On platforms where only one data-model is supported
- * (e.g. ia-64 Linux), using the flag for the other data model is
- * an error and will terminate the program.
- */
-
- { /* open new scope to declare local variables */
- int i;
-
- newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(*newargv));
- newargv[newargc++] = argv[0];
-
- /* scan for data model arguments and remove from argument list;
- last occurrence determines desired data model */
- for (i=1; i < argc; i++) {
-
- if (strcmp(argv[i], "-J-d64") == 0 || strcmp(argv[i], "-d64") == 0) {
- wanted = 64;
- continue;
- }
- if (strcmp(argv[i], "-J-d32") == 0 || strcmp(argv[i], "-d32") == 0) {
- wanted = 32;
- continue;
- }
- newargv[newargc++] = argv[i];
-
-#ifdef JAVA_ARGS
- if (argv[i][0] != '-')
- continue;
-#else
- if (strcmp(argv[i], "-classpath") == 0 || strcmp(argv[i], "-cp") == 0) {
- i++;
- if (i >= argc) break;
- newargv[newargc++] = argv[i];
- continue;
- }
- if (argv[i][0] != '-') { i++; break; }
-#endif
- }
-
- /* copy rest of args [i .. argc) */
- while (i < argc) {
- newargv[newargc++] = argv[i++];
- }
- newargv[newargc] = NULL;
-
- /*
- * newargv has all proper arguments here
- */
-
- argc = newargc;
- argv = newargv;
- }
-
- /* If the data model is not changing, it is an error if the
- jvmpath does not exist */
- if (wanted == running) {
- /* Find out where the JRE is that we will be using. */
- if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
- fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
- exit(2);
- }
-
- /* Find the specified JVM type */
- if (ReadKnownVMs(jrepath, arch, JNI_FALSE) < 1) {
- fprintf(stderr, "Error: no known VMs. (check for corrupt jvm.cfg file)\n");
- exit(1);
- }
-
- jvmpath[0] = '\0';
- jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE);
-
- if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) {
- fprintf(stderr, "Error: no `%s' JVM at `%s'.\n", jvmtype, jvmpath);
- exit(4);
- }
- } else { /* do the same speculatively or exit */
-#ifdef DUAL_MODE
- if (running != wanted) {
- /* Find out where the JRE is that we will be using. */
- if (!GetJREPath(jrepath, so_jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME), JNI_TRUE)) {
- goto EndDataModelSpeculate;
- }
-
- /*
- * Read in jvm.cfg for target data model and process vm
- * selection options.
- */
- if (ReadKnownVMs(jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME), JNI_TRUE) < 1) {
- goto EndDataModelSpeculate;
- }
- jvmpath[0] = '\0';
- jvmtype = CheckJvmType(_argcp, _argvp, JNI_TRUE);
- /* exec child can do error checking on the existence of the path */
- jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath,
- ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME));
-
- }
- EndDataModelSpeculate: /* give up and let other code report error message */
- ;
-#else
- fprintf(stderr, "Running a %d-bit JVM is not supported on this platform.\n", wanted);
- exit(1);
-#endif
- }
-
- /*
- * We will set the LD_LIBRARY_PATH as follows:
- *
- * o $JVMPATH (directory portion only)
- * o $JRE/lib/$LIBARCHNAME
- * o $JRE/../lib/$LIBARCHNAME
- *
- * followed by the user's previous effective LD_LIBRARY_PATH, if
- * any.
- */
-
-#ifdef __sun
- /*
- * Starting in Solaris 7, ld.so.1 supports three LD_LIBRARY_PATH
- * variables:
- *
- * 1. LD_LIBRARY_PATH -- used for 32 and 64 bit searches if
- * data-model specific variables are not set.
- *
- * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH
- * for 64-bit binaries.
- *
- * 3. LD_LIBRARY_PATH_32 -- overrides and replaces LD_LIBRARY_PATH
- * for 32-bit binaries.
- *
- * The vm uses LD_LIBRARY_PATH to set the java.library.path system
- * property. To shield the vm from the complication of multiple
- * LD_LIBRARY_PATH variables, if the appropriate data model
- * specific variable is set, we will act as if LD_LIBRARY_PATH had
- * the value of the data model specific variant and the data model
- * specific variant will be unset. Note that the variable for the
- * *wanted* data model must be used (if it is set), not simply the
- * current running data model.
- */
-
- switch(wanted) {
- case 0:
- if(running == 32) {
- dmpath = getenv("LD_LIBRARY_PATH_32");
- wanted = 32;
- }
- else {
- dmpath = getenv("LD_LIBRARY_PATH_64");
- wanted = 64;
- }
- break;
-
- case 32:
- dmpath = getenv("LD_LIBRARY_PATH_32");
- break;
-
- case 64:
- dmpath = getenv("LD_LIBRARY_PATH_64");
- break;
-
- default:
- fprintf(stderr, "Improper value at line %d.", __LINE__);
- exit(1); /* unknown value in wanted */
- break;
- }
-
- /*
- * If dmpath is NULL, the relevant data model specific variable is
- * not set and normal LD_LIBRARY_PATH should be used.
- */
- if( dmpath == NULL) {
- runpath = getenv("LD_LIBRARY_PATH");
- }
- else {
- runpath = dmpath;
- }
-#else
- /*
- * If not on Solaris, assume only a single LD_LIBRARY_PATH
- * variable.
- */
- runpath = getenv(LD_LIBRARY_PATH);
-#endif /* __sun */
-
-#if defined(__linux__)
- /*
- * On linux, if a binary is running as sgid or suid, glibc sets
- * LD_LIBRARY_PATH to the empty string for security purposes. (In
- * contrast, on Solaris the LD_LIBRARY_PATH variable for a
- * privileged binary does not lose its settings; but the dynamic
- * linker does apply more scrutiny to the path.) The launcher uses
- * the value of LD_LIBRARY_PATH to prevent an exec loop.
- * Therefore, if we are running sgid or suid, this function's
- * setting of LD_LIBRARY_PATH will be ineffective and we should
- * return from the function now. Getting the right libraries to
- * be found must be handled through other mechanisms.
- */
- if((getgid() != getegid()) || (getuid() != geteuid()) ) {
- return;
- }
-#elif defined(_ALLBSD_SOURCE)
- /*
- * On BSD, if a binary is running as sgid or suid, libc sets
- * LD_LIBRARY_PATH to the empty string for security purposes. (In
- * contrast, on Solaris the LD_LIBRARY_PATH variable for a
- * privileged binary does not lose its settings; but the dynamic
- * linker does apply more scrutiny to the path.) The launcher uses
- * the value of LD_LIBRARY_PATH to prevent an exec loop.
- * Therefore, if we are running sgid or suid, this function's
- * setting of LD_LIBRARY_PATH will be ineffective and we should
- * return from the function now. Getting the right libraries to
- * be found must be handled through other mechanisms.
- */
- if(issetugid()) {
- return;
- }
-#endif
-
- /* runpath contains current effective LD_LIBRARY_PATH setting */
-
- jvmpath = JLI_StringDup(jvmpath);
- new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) +
- 2*strlen(jrepath) + 2*strlen(arch) +
- strlen(jvmpath) + 52);
- newpath = new_runpath + strlen(LD_LIBRARY_PATH "=");
-
-
- /*
- * Create desired LD_LIBRARY_PATH value for target data model.
- */
- {
- /* remove the name of the .so from the JVM path */
- lastslash = strrchr(jvmpath, '/');
- if (lastslash)
- *lastslash = '\0';
-
-
- /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */
-
- sprintf(new_runpath, LD_LIBRARY_PATH "="
- "%s:"
- "%s/lib/%s:"
- "%s/../lib/%s",
- jvmpath,
-#ifdef DUAL_MODE
- jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME),
- jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME)
-#else
- jrepath, arch,
- jrepath, arch
-#endif
- );
-
-
- /*
- * Check to make sure that the prefix of the current path is the
- * desired environment variable setting.
- */
- if (runpath != NULL &&
- strncmp(newpath, runpath, strlen(newpath))==0 &&
- (runpath[strlen(newpath)] == 0 || runpath[strlen(newpath)] == ':') &&
- (running == wanted) /* data model does not have to be changed */
-#ifdef __sun
- && (dmpath == NULL) /* data model specific variables not set */
-#endif
- ) {
-
- return;
-
- }
- }
-
- /*
- * Place the desired environment setting onto the prefix of
- * LD_LIBRARY_PATH. Note that this prevents any possible infinite
- * loop of execv() because we test for the prefix, above.
- */
- if (runpath != 0) {
- strcat(new_runpath, ":");
- strcat(new_runpath, runpath);
- }
-
- if( putenv(new_runpath) != 0) {
- exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set
- properly */
- }
-
- /*
- * Unix systems document that they look at LD_LIBRARY_PATH only
- * once at startup, so we have to re-exec the current executable
- * to get the changed environment variable to have an effect.
- */
-
-#ifdef __sun
- /*
- * If dmpath is not NULL, remove the data model specific string
- * in the environment for the exec'ed child.
- */
-
- if( dmpath != NULL)
- (void)UnsetEnv((wanted==32)?"LD_LIBRARY_PATH_32":"LD_LIBRARY_PATH_64");
-#endif
-
- newenvp = environ;
-
- {
- char *newexec = execname;
-#ifdef DUAL_MODE
- /*
- * If the data model is being changed, the path to the
- * executable must be updated accordingly; the executable name
- * and directory the executable resides in are separate. In the
- * case of 32 => 64, the new bits are assumed to reside in, e.g.
- * "olddir/LIBARCH64NAME/execname"; in the case of 64 => 32,
- * the bits are assumed to be in "olddir/../execname". For example,
- *
- * olddir/sparcv9/execname
- * olddir/amd64/execname
- *
- * for Solaris SPARC and Linux amd64, respectively.
- */
-
- if (running != wanted) {
- char *oldexec = strcpy(JLI_MemAlloc(strlen(execname) + 1), execname);
- char *olddir = oldexec;
- char *oldbase = strrchr(oldexec, '/');
-
-
- newexec = JLI_MemAlloc(strlen(execname) + 20);
- *oldbase++ = 0;
- sprintf(newexec, "%s/%s/%s", olddir,
- ((wanted==64) ? LIBARCH64NAME : ".."), oldbase);
- argv[0] = newexec;
- }
-#endif
-
- (void)fflush(stdout);
- (void)fflush(stderr);
- execve(newexec, argv, newenvp);
- perror("execve()");
-
- fprintf(stderr, "Error trying to exec %s.\n", newexec);
- fprintf(stderr, "Check if file exists and permissions are set correctly.\n");
-
-#ifdef DUAL_MODE
- if (running != wanted) {
- fprintf(stderr, "Failed to start a %d-bit JVM process from a %d-bit JVM.\n",
- wanted, running);
-# ifdef __sun
-
-# ifdef __sparc
- fprintf(stderr, "Verify all necessary J2SE components have been installed.\n" );
- fprintf(stderr,
- "(Solaris SPARC 64-bit components must be installed after 32-bit components.)\n" );
-# else
- fprintf(stderr, "Either 64-bit processes are not supported by this platform\n");
- fprintf(stderr, "or the 64-bit components have not been installed.\n");
-# endif
- }
-# endif
-#endif
-
- }
-
- exit(1);
- }
-
-#else /* ifndef GAMMA */
-
- /*
- * gamma launcher is simpler in that it doesn't handle VM flavors, data
- * model, LD_LIBRARY_PATH, etc. Assuming everything is set-up correctly
- * all we need to do here is to return correct path names. See also
- * GetJVMPath() and GetApplicationHome().
- */
-
- { char *arch = (char *) ARCH; /* like sparc or sparcv9 */
- char *p;
-
- if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
- fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
- exit(2);
- }
-
- if (!GetJVMPath(jrepath, NULL, jvmpath, so_jvmpath, arch )) {
- fprintf(stderr, "Error: no JVM at `%s'.\n", jvmpath);
- exit(4);
- }
- }
-
-#endif /* ifndef GAMMA */
-}
-
-
-/*
- * On Solaris VM choosing is done by the launcher (java.c).
- */
-static jboolean
-GetJVMPath(const char *jrepath, const char *jvmtype,
- char *jvmpath, jint jvmpathsize, char * arch)
-{
- struct stat s;
-
-#ifndef GAMMA
- if (strchr(jvmtype, '/')) {
- sprintf(jvmpath, "%s/" JVM_DLL, jvmtype);
- } else {
- sprintf(jvmpath, "%s/lib/%s/%s/" JVM_DLL, jrepath, arch, jvmtype);
- }
-#else
- /*
- * For gamma launcher, JVM is either built-in or in the same directory.
- * Either way we return "/libjvm.so" where is the
- * directory where gamma launcher is located.
- */
-
- char *p;
-
- snprintf(jvmpath, jvmpathsize, "%s", GetExecname());
- p = strrchr(jvmpath, '/');
- if (p) {
- /* replace executable name with libjvm.so */
- snprintf(p + 1, jvmpathsize - (p + 1 - jvmpath), "%s", JVM_DLL);
- } else {
- /* this case shouldn't happen */
- snprintf(jvmpath, jvmpathsize, "%s", JVM_DLL);
- }
-#endif /* ifndef GAMMA */
-
- if (_launcher_debug)
- printf("Does `%s' exist ... ", jvmpath);
-
- if (stat(jvmpath, &s) == 0) {
- if (_launcher_debug)
- printf("yes.\n");
- return JNI_TRUE;
- } else {
- if (_launcher_debug)
- printf("no.\n");
- return JNI_FALSE;
- }
-}
-
-/*
- * Find path to JRE based on .exe's location or registry settings.
- */
-static jboolean
-GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative)
-{
- char libjava[MAXPATHLEN];
-
- if (GetApplicationHome(path, pathsize)) {
-
- /* Is the JRE universal, i.e. no arch dir? */
- sprintf(libjava, "%s/jre/lib/" JAVA_DLL, path);
- if (access(libjava, F_OK) == 0) {
- strcat(path, "/jre");
- goto found;
- }
-
- /* Is JRE co-located with the application? */
- sprintf(libjava, "%s/lib/%s/" JAVA_DLL, path, arch);
- if (access(libjava, F_OK) == 0) {
- goto found;
- }
-
- /* Does the app ship a private JRE in /jre directory? */
- sprintf(libjava, "%s/jre/lib/%s/" JAVA_DLL, path, arch);
- if (access(libjava, F_OK) == 0) {
- strcat(path, "/jre");
- goto found;
- }
- }
-
- if (!speculative)
- fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
- return JNI_FALSE;
-
- found:
- if (_launcher_debug)
- printf("JRE path is %s\n", path);
- return JNI_TRUE;
-}
-
-jboolean
-LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
-{
-#ifdef GAMMA
- /* JVM is directly linked with gamma launcher; no dlopen() */
- ifn->CreateJavaVM = JNI_CreateJavaVM;
- ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
- return JNI_TRUE;
-#else
- Dl_info dlinfo;
- void *libjvm;
-
- if (_launcher_debug) {
- printf("JVM path is %s\n", jvmpath);
- }
-
- libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
- if (libjvm == NULL) {
-#if defined(__sparc) && !defined(_LP64) /* i.e. 32-bit sparc */
- FILE * fp;
- Elf32_Ehdr elf_head;
- int count;
- int location;
-
- fp = fopen(jvmpath, "r");
- if(fp == NULL)
- goto error;
-
- /* read in elf header */
- count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp);
- fclose(fp);
- if(count < 1)
- goto error;
-
- /*
- * Check for running a server vm (compiled with -xarch=v8plus)
- * on a stock v8 processor. In this case, the machine type in
- * the elf header would not be included the architecture list
- * provided by the isalist command, which is turn is gotten from
- * sysinfo. This case cannot occur on 64-bit hardware and thus
- * does not have to be checked for in binaries with an LP64 data
- * model.
- */
- if(elf_head.e_machine == EM_SPARC32PLUS) {
- char buf[257]; /* recommended buffer size from sysinfo man
- page */
- long length;
- char* location;
-
- length = sysinfo(SI_ISALIST, buf, 257);
- if(length > 0) {
- location = strstr(buf, "sparcv8plus ");
- if(location == NULL) {
- fprintf(stderr, "SPARC V8 processor detected; Server compiler requires V9 or better.\n");
- fprintf(stderr, "Use Client compiler on V8 processors.\n");
- fprintf(stderr, "Could not create the Java virtual machine.\n");
- return JNI_FALSE;
- }
- }
- }
-#endif
- fprintf(stderr, "dl failure on line %d", __LINE__);
- goto error;
- }
-
- ifn->CreateJavaVM = (CreateJavaVM_t)
- dlsym(libjvm, "JNI_CreateJavaVM");
- if (ifn->CreateJavaVM == NULL)
- goto error;
-
- ifn->GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)
- dlsym(libjvm, "JNI_GetDefaultJavaVMInitArgs");
- if (ifn->GetDefaultJavaVMInitArgs == NULL)
- goto error;
-
- return JNI_TRUE;
-
-error:
- fprintf(stderr, "Error: failed %s, because %s\n", jvmpath, dlerror());
- return JNI_FALSE;
-#endif /* ifndef GAMMA */
-}
-
-/*
- * If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put
- * "/foo" into buf.
- */
-jboolean
-GetApplicationHome(char *buf, jint bufsize)
-{
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
- char *execname = GetExecname();
- if (execname) {
- strncpy(buf, execname, bufsize-1);
- buf[bufsize-1] = '\0';
- } else {
- return JNI_FALSE;
- }
-#else
- Dl_info dlinfo;
-
- dladdr((void *)GetApplicationHome, &dlinfo);
- if (realpath(dlinfo.dli_fname, buf) == NULL) {
- fprintf(stderr, "Error: realpath(`%s') failed.\n", dlinfo.dli_fname);
- return JNI_FALSE;
- }
-#endif
-
-#ifdef GAMMA
- {
- /* gamma launcher uses JAVA_HOME environment variable to find JDK/JRE */
- char* java_home_var = getenv("JAVA_HOME");
- if (java_home_var == NULL) {
- printf("JAVA_HOME must point to a valid JDK/JRE to run gamma\n");
- return JNI_FALSE;
- }
- snprintf(buf, bufsize, "%s", java_home_var);
- }
-#else
- if (strrchr(buf, '/') == 0) {
- buf[0] = '\0';
- return JNI_FALSE;
- }
- *(strrchr(buf, '/')) = '\0'; /* executable file */
- if (strlen(buf) < 4 || strrchr(buf, '/') == 0) {
- buf[0] = '\0';
- return JNI_FALSE;
- }
- if (strcmp("/bin", buf + strlen(buf) - 4) != 0)
- *(strrchr(buf, '/')) = '\0'; /* sparcv9 or amd64 */
- if (strlen(buf) < 4 || strcmp("/bin", buf + strlen(buf) - 4) != 0) {
- buf[0] = '\0';
- return JNI_FALSE;
- }
- *(strrchr(buf, '/')) = '\0'; /* bin */
-#endif /* ifndef GAMMA */
-
- return JNI_TRUE;
-}
-
-
-/*
- * Return true if the named program exists
- */
-static int
-ProgramExists(char *name)
-{
- struct stat sb;
- if (stat(name, &sb) != 0) return 0;
- if (S_ISDIR(sb.st_mode)) return 0;
- return (sb.st_mode & S_IEXEC) != 0;
-}
-
-
-/*
- * Find a command in a directory, returning the path.
- */
-static char *
-Resolve(char *indir, char *cmd)
-{
- char name[PATH_MAX + 2], *real;
-
- if ((strlen(indir) + strlen(cmd) + 1) > PATH_MAX) return 0;
- sprintf(name, "%s%c%s", indir, FILE_SEPARATOR, cmd);
- if (!ProgramExists(name)) return 0;
- real = JLI_MemAlloc(PATH_MAX + 2);
- if (!realpath(name, real))
- strcpy(real, name);
- return real;
-}
-
-
-/*
- * Find a path for the executable
- */
-static char *
-FindExecName(char *program)
-{
- char cwdbuf[PATH_MAX+2];
- char *path;
- char *tmp_path;
- char *f;
- char *result = NULL;
-
- /* absolute path? */
- if (*program == FILE_SEPARATOR ||
- (FILE_SEPARATOR=='\\' && strrchr(program, ':')))
- return Resolve("", program+1);
-
- /* relative path? */
- if (strrchr(program, FILE_SEPARATOR) != 0) {
- char buf[PATH_MAX+2];
- return Resolve(getcwd(cwdbuf, sizeof(cwdbuf)), program);
- }
-
- /* from search path? */
- path = getenv("PATH");
- if (!path || !*path) path = ".";
- tmp_path = JLI_MemAlloc(strlen(path) + 2);
- strcpy(tmp_path, path);
-
- for (f=tmp_path; *f && result==0; ) {
- char *s = f;
- while (*f && (*f != PATH_SEPARATOR)) ++f;
- if (*f) *f++ = 0;
- if (*s == FILE_SEPARATOR)
- result = Resolve(s, program);
- else {
- /* relative path element */
- char dir[2*PATH_MAX];
- sprintf(dir, "%s%c%s", getcwd(cwdbuf, sizeof(cwdbuf)),
- FILE_SEPARATOR, s);
- result = Resolve(dir, program);
- }
- if (result != 0) break;
- }
-
- JLI_MemFree(tmp_path);
- return result;
-}
-
-
-/* Store the name of the executable once computed */
-static char *execname = NULL;
-
-/*
- * Compute the name of the executable
- *
- * In order to re-exec securely we need the absolute path of the
- * executable. On Solaris getexecname(3c) may not return an absolute
- * path so we use dladdr to get the filename of the executable and
- * then use realpath to derive an absolute path. From Solaris 9
- * onwards the filename returned in DL_info structure from dladdr is
- * an absolute pathname so technically realpath isn't required.
- * On Linux we read the executable name from /proc/self/exe.
- * As a fallback, and for platforms other than Solaris and Linux,
- * we use FindExecName to compute the executable name.
- */
-static char *
-SetExecname(char **argv)
-{
- char* exec_path = NULL;
-
- if (execname != NULL) /* Already determined */
- return (execname);
-
-#if defined(__sun)
- {
- Dl_info dlinfo;
- if (dladdr((void*)&SetExecname, &dlinfo)) {
- char *resolved = (char*)JLI_MemAlloc(PATH_MAX+1);
- if (resolved != NULL) {
- exec_path = realpath(dlinfo.dli_fname, resolved);
- if (exec_path == NULL) {
- JLI_MemFree(resolved);
- }
- }
- }
- }
-#elif defined(__linux__)
- {
- const char* self = "/proc/self/exe";
- char buf[PATH_MAX+1];
- int len = readlink(self, buf, PATH_MAX);
- if (len >= 0) {
- buf[len] = '\0'; /* readlink doesn't nul terminate */
- exec_path = JLI_StringDup(buf);
- }
- }
-#else /* !__sun && !__linux */
- {
- /* Not implemented */
- }
-#endif
-
- if (exec_path == NULL) {
- exec_path = FindExecName(argv[0]);
- }
- execname = exec_path;
- return exec_path;
-}
-
-/*
- * Return the name of the executable. Used in java_md.c to find the JRE area.
- */
-static char *
-GetExecname() {
- return execname;
-}
-
-void ReportErrorMessage(char * message, jboolean always) {
- if (always) {
- fprintf(stderr, "%s\n", message);
- }
-}
-
-void ReportErrorMessage2(char * format, char * string, jboolean always) {
- if (always) {
- fprintf(stderr, format, string);
- fprintf(stderr, "\n");
- }
-}
-
-void ReportExceptionDescription(JNIEnv * env) {
- (*env)->ExceptionDescribe(env);
-}
-
-/*
- * Return JNI_TRUE for an option string that has no effect but should
- * _not_ be passed on to the vm; return JNI_FALSE otherwise. On
- * Solaris SPARC, this screening needs to be done if:
- * 1) LD_LIBRARY_PATH does _not_ need to be reset and
- * 2) -d32 or -d64 is passed to a binary with a matching data model
- * (the exec in SetLibraryPath removes -d options and points the
- * exec to the proper binary). When this exec is not done, these options
- * would end up getting passed onto the vm.
- */
-jboolean RemovableMachineDependentOption(char * option) {
- /*
- * Unconditionally remove both -d32 and -d64 options since only
- * the last such options has an effect; e.g.
- * java -d32 -d64 -d32 -version
- * is equivalent to
- * java -d32 -version
- */
-
- if( (strcmp(option, "-d32") == 0 ) ||
- (strcmp(option, "-d64") == 0 ))
- return JNI_TRUE;
- else
- return JNI_FALSE;
-}
-
-void PrintMachineDependentOptions() {
- fprintf(stdout,
- " -d32 use a 32-bit data model if available\n"
- "\n"
- " -d64 use a 64-bit data model if available\n");
- return;
-}
-
-#ifndef GAMMA
-/*
- * The following methods (down to ServerClassMachine()) answer
- * the question about whether a machine is a "server-class"
- * machine. A server-class machine is loosely defined as one
- * with 2 or more processors and 2 gigabytes or more physical
- * memory. The definition of a processor is a physical package,
- * not a hyperthreaded chip masquerading as a multi-processor.
- * The definition of memory is also somewhat fuzzy, since x86
- * machines seem not to report all the memory in their DIMMs, we
- * think because of memory mapping of graphics cards, etc.
- *
- * This code is somewhat more confused with #ifdef's than we'd
- * like because this file is used by both Solaris and Linux
- * platforms, and so needs to be parameterized for SPARC and
- * i586 hardware. The other Linux platforms (amd64 and ia64)
- * don't even ask this question, because they only come with
- * server JVMs. */
-
-# define KB (1024UL)
-# define MB (1024UL * KB)
-# define GB (1024UL * MB)
-
-/* Compute physical memory by asking the OS */
-uint64_t
-physical_memory(void) {
- const uint64_t pages = (uint64_t) sysconf(_SC_PHYS_PAGES);
- const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE);
- const uint64_t result = pages * page_size;
-# define UINT64_FORMAT "%" PRIu64
-
- if (_launcher_debug) {
- printf("pages: " UINT64_FORMAT
- " page_size: " UINT64_FORMAT
- " physical memory: " UINT64_FORMAT " (%.3fGB)\n",
- pages, page_size, result, result / (double) GB);
- }
- return result;
-}
-
-#if defined(__sun) && defined(__sparc)
-
-/* Methods for solaris-sparc: these are easy. */
-
-/* Ask the OS how many processors there are. */
-unsigned long
-physical_processors(void) {
- const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
-
- if (_launcher_debug) {
- printf("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
- }
- return sys_processors;
-}
-
-/* The solaris-sparc version of the "server-class" predicate. */
-jboolean
-solaris_sparc_ServerClassMachine(void) {
- jboolean result = JNI_FALSE;
- /* How big is a server class machine? */
- const unsigned long server_processors = 2UL;
- const uint64_t server_memory = 2UL * GB;
- const uint64_t actual_memory = physical_memory();
-
- /* Is this a server class machine? */
- if (actual_memory >= server_memory) {
- const unsigned long actual_processors = physical_processors();
- if (actual_processors >= server_processors) {
- result = JNI_TRUE;
- }
- }
- if (_launcher_debug) {
- printf("solaris_" LIBARCHNAME "_ServerClassMachine: %s\n",
- (result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE"));
- }
- return result;
-}
-
-#endif /* __sun && __sparc */
-
-#if defined(__sun) && defined(i586)
-
-/*
- * A utility method for asking the CPU about itself.
- * There's a corresponding version of linux-i586
- * because the compilers are different.
- */
-void
-get_cpuid(uint32_t arg,
- uint32_t* eaxp,
- uint32_t* ebxp,
- uint32_t* ecxp,
- uint32_t* edxp) {
-#ifdef _LP64
- asm(
- /* rbx is a callee-saved register */
- " movq %rbx, %r11 \n"
- /* rdx and rcx are 3rd and 4th argument registers */
- " movq %rdx, %r10 \n"
- " movq %rcx, %r9 \n"
- " movl %edi, %eax \n"
- " cpuid \n"
- " movl %eax, (%rsi)\n"
- " movl %ebx, (%r10)\n"
- " movl %ecx, (%r9) \n"
- " movl %edx, (%r8) \n"
- /* Restore rbx */
- " movq %r11, %rbx");
-#else
- /* EBX is a callee-saved register */
- asm(" pushl %ebx");
- /* Need ESI for storing through arguments */
- asm(" pushl %esi");
- asm(" movl 8(%ebp), %eax \n"
- " cpuid \n"
- " movl 12(%ebp), %esi \n"
- " movl %eax, (%esi) \n"
- " movl 16(%ebp), %esi \n"
- " movl %ebx, (%esi) \n"
- " movl 20(%ebp), %esi \n"
- " movl %ecx, (%esi) \n"
- " movl 24(%ebp), %esi \n"
- " movl %edx, (%esi) ");
- /* Restore ESI and EBX */
- asm(" popl %esi");
- /* Restore EBX */
- asm(" popl %ebx");
-#endif
-}
-
-#endif /* __sun && i586 */
-
-#if (defined(__linux__) || defined(_ALLBSD_SOURCE)) && defined(i586)
-
-/*
- * A utility method for asking the CPU about itself.
- * There's a corresponding version of solaris-i586
- * because the compilers are different.
- */
-void
-get_cpuid(uint32_t arg,
- uint32_t* eaxp,
- uint32_t* ebxp,
- uint32_t* ecxp,
- uint32_t* edxp) {
-#ifdef _LP64
- __asm__ volatile (/* Instructions */
- " movl %4, %%eax \n"
- " cpuid \n"
- " movl %%eax, (%0)\n"
- " movl %%ebx, (%1)\n"
- " movl %%ecx, (%2)\n"
- " movl %%edx, (%3)\n"
- : /* Outputs */
- : /* Inputs */
- "r" (eaxp),
- "r" (ebxp),
- "r" (ecxp),
- "r" (edxp),
- "r" (arg)
- : /* Clobbers */
- "%rax", "%rbx", "%rcx", "%rdx", "memory"
- );
-#else
- uint32_t value_of_eax = 0;
- uint32_t value_of_ebx = 0;
- uint32_t value_of_ecx = 0;
- uint32_t value_of_edx = 0;
- __asm__ volatile (/* Instructions */
- /* ebx is callee-save, so push it */
- " pushl %%ebx \n"
- " movl %4, %%eax \n"
- " cpuid \n"
- " movl %%eax, %0 \n"
- " movl %%ebx, %1 \n"
- " movl %%ecx, %2 \n"
- " movl %%edx, %3 \n"
- /* restore ebx */
- " popl %%ebx \n"
-
- : /* Outputs */
- "=m" (value_of_eax),
- "=m" (value_of_ebx),
- "=m" (value_of_ecx),
- "=m" (value_of_edx)
- : /* Inputs */
- "m" (arg)
- : /* Clobbers */
- "%eax", "%ecx", "%edx"
- );
- *eaxp = value_of_eax;
- *ebxp = value_of_ebx;
- *ecxp = value_of_ecx;
- *edxp = value_of_edx;
-#endif
-}
-
-#endif /* __linux__ && i586 */
-
-#ifdef i586
-/*
- * Routines shared by solaris-i586 and linux-i586.
- */
-
-enum HyperThreadingSupport_enum {
- hts_supported = 1,
- hts_too_soon_to_tell = 0,
- hts_not_supported = -1,
- hts_not_pentium4 = -2,
- hts_not_intel = -3
-};
-typedef enum HyperThreadingSupport_enum HyperThreadingSupport;
-
-/* Determine if hyperthreading is supported */
-HyperThreadingSupport
-hyperthreading_support(void) {
- HyperThreadingSupport result = hts_too_soon_to_tell;
- /* Bits 11 through 8 is family processor id */
-# define FAMILY_ID_SHIFT 8
-# define FAMILY_ID_MASK 0xf
- /* Bits 23 through 20 is extended family processor id */
-# define EXT_FAMILY_ID_SHIFT 20
-# define EXT_FAMILY_ID_MASK 0xf
- /* Pentium 4 family processor id */
-# define PENTIUM4_FAMILY_ID 0xf
- /* Bit 28 indicates Hyper-Threading Technology support */
-# define HT_BIT_SHIFT 28
-# define HT_BIT_MASK 1
- uint32_t vendor_id[3] = { 0U, 0U, 0U };
- uint32_t value_of_eax = 0U;
- uint32_t value_of_edx = 0U;
- uint32_t dummy = 0U;
-
- /* Yes, this is supposed to be [0], [2], [1] */
- get_cpuid(0, &dummy, &vendor_id[0], &vendor_id[2], &vendor_id[1]);
- if (_launcher_debug) {
- printf("vendor: %c %c %c %c %c %c %c %c %c %c %c %c \n",
- ((vendor_id[0] >> 0) & 0xff),
- ((vendor_id[0] >> 8) & 0xff),
- ((vendor_id[0] >> 16) & 0xff),
- ((vendor_id[0] >> 24) & 0xff),
- ((vendor_id[1] >> 0) & 0xff),
- ((vendor_id[1] >> 8) & 0xff),
- ((vendor_id[1] >> 16) & 0xff),
- ((vendor_id[1] >> 24) & 0xff),
- ((vendor_id[2] >> 0) & 0xff),
- ((vendor_id[2] >> 8) & 0xff),
- ((vendor_id[2] >> 16) & 0xff),
- ((vendor_id[2] >> 24) & 0xff));
- }
- get_cpuid(1, &value_of_eax, &dummy, &dummy, &value_of_edx);
- if (_launcher_debug) {
- printf("value_of_eax: 0x%x value_of_edx: 0x%x\n",
- value_of_eax, value_of_edx);
- }
- if ((((value_of_eax >> FAMILY_ID_SHIFT) & FAMILY_ID_MASK) == PENTIUM4_FAMILY_ID) ||
- (((value_of_eax >> EXT_FAMILY_ID_SHIFT) & EXT_FAMILY_ID_MASK) != 0)) {
- if ((((vendor_id[0] >> 0) & 0xff) == 'G') &&
- (((vendor_id[0] >> 8) & 0xff) == 'e') &&
- (((vendor_id[0] >> 16) & 0xff) == 'n') &&
- (((vendor_id[0] >> 24) & 0xff) == 'u') &&
- (((vendor_id[1] >> 0) & 0xff) == 'i') &&
- (((vendor_id[1] >> 8) & 0xff) == 'n') &&
- (((vendor_id[1] >> 16) & 0xff) == 'e') &&
- (((vendor_id[1] >> 24) & 0xff) == 'I') &&
- (((vendor_id[2] >> 0) & 0xff) == 'n') &&
- (((vendor_id[2] >> 8) & 0xff) == 't') &&
- (((vendor_id[2] >> 16) & 0xff) == 'e') &&
- (((vendor_id[2] >> 24) & 0xff) == 'l')) {
- if (((value_of_edx >> HT_BIT_SHIFT) & HT_BIT_MASK) == HT_BIT_MASK) {
- if (_launcher_debug) {
- printf("Hyperthreading supported\n");
- }
- result = hts_supported;
- } else {
- if (_launcher_debug) {
- printf("Hyperthreading not supported\n");
- }
- result = hts_not_supported;
- }
- } else {
- if (_launcher_debug) {
- printf("Not GenuineIntel\n");
- }
- result = hts_not_intel;
- }
- } else {
- if (_launcher_debug) {
- printf("not Pentium 4 or extended\n");
- }
- result = hts_not_pentium4;
- }
- return result;
-}
-
-/* Determine how many logical processors there are per CPU */
-unsigned int
-logical_processors_per_package(void) {
- /*
- * After CPUID with EAX==1, register EBX bits 23 through 16
- * indicate the number of logical processors per package
- */
-# define NUM_LOGICAL_SHIFT 16
-# define NUM_LOGICAL_MASK 0xff
- unsigned int result = 1U;
- const HyperThreadingSupport hyperthreading = hyperthreading_support();
-
- if (hyperthreading == hts_supported) {
- uint32_t value_of_ebx = 0U;
- uint32_t dummy = 0U;
-
- get_cpuid(1, &dummy, &value_of_ebx, &dummy, &dummy);
- result = (value_of_ebx >> NUM_LOGICAL_SHIFT) & NUM_LOGICAL_MASK;
- if (_launcher_debug) {
- printf("logical processors per package: %u\n", result);
- }
- }
- return result;
-}
-
-/* Compute the number of physical processors, not logical processors */
-unsigned long
-physical_processors(void) {
- const long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
- unsigned long result = sys_processors;
-
- if (_launcher_debug) {
- printf("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
- }
- if (sys_processors > 1) {
- unsigned int logical_processors = logical_processors_per_package();
- if (logical_processors > 1) {
- result = (unsigned long) sys_processors / logical_processors;
- }
- }
- if (_launcher_debug) {
- printf("physical processors: %lu\n", result);
- }
- return result;
-}
-
-#endif /* i586 */
-
-#if defined(__sun) && defined(i586)
-
-/* The definition of a server-class machine for solaris-i586/amd64 */
-jboolean
-solaris_i586_ServerClassMachine(void) {
- jboolean result = JNI_FALSE;
- /* How big is a server class machine? */
- const unsigned long server_processors = 2UL;
- const uint64_t server_memory = 2UL * GB;
- /*
- * We seem not to get our full complement of memory.
- * We allow some part (1/8?) of the memory to be "missing",
- * based on the sizes of DIMMs, and maybe graphics cards.
- */
- const uint64_t missing_memory = 256UL * MB;
- const uint64_t actual_memory = physical_memory();
-
- /* Is this a server class machine? */
- if (actual_memory >= (server_memory - missing_memory)) {
- const unsigned long actual_processors = physical_processors();
- if (actual_processors >= server_processors) {
- result = JNI_TRUE;
- }
- }
- if (_launcher_debug) {
- printf("solaris_" LIBARCHNAME "_ServerClassMachine: %s\n",
- (result == JNI_TRUE ? "true" : "false"));
- }
- return result;
-}
-
-#endif /* __sun && i586 */
-
-#if defined(__linux__) && defined(i586)
-
-/* The definition of a server-class machine for linux-i586 */
-jboolean
-linux_i586_ServerClassMachine(void) {
- jboolean result = JNI_FALSE;
- /* How big is a server class machine? */
- const unsigned long server_processors = 2UL;
- const uint64_t server_memory = 2UL * GB;
- /*
- * We seem not to get our full complement of memory.
- * We allow some part (1/8?) of the memory to be "missing",
- * based on the sizes of DIMMs, and maybe graphics cards.
- */
- const uint64_t missing_memory = 256UL * MB;
- const uint64_t actual_memory = physical_memory();
-
- /* Is this a server class machine? */
- if (actual_memory >= (server_memory - missing_memory)) {
- const unsigned long actual_processors = physical_processors();
- if (actual_processors >= server_processors) {
- result = JNI_TRUE;
- }
- }
- if (_launcher_debug) {
- printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
- (result == JNI_TRUE ? "true" : "false"));
- }
- return result;
-}
-
-#endif /* __linux__ && i586 */
-
-#if defined(_ALLBSD_SOURCE) && defined(i586)
-
-/* The definition of a server-class machine for bsd-i586 */
-jboolean
-bsd_i586_ServerClassMachine(void) {
- jboolean result = JNI_FALSE;
- /* How big is a server class machine? */
- const unsigned long server_processors = 2UL;
- const uint64_t server_memory = 2UL * GB;
- /*
- * We seem not to get our full complement of memory.
- * We allow some part (1/8?) of the memory to be "missing",
- * based on the sizes of DIMMs, and maybe graphics cards.
- */
- const uint64_t missing_memory = 256UL * MB;
- const uint64_t actual_memory = physical_memory();
-
- /* Is this a server class machine? */
- if (actual_memory >= (server_memory - missing_memory)) {
- const unsigned long actual_processors = physical_processors();
- if (actual_processors >= server_processors) {
- result = JNI_TRUE;
- }
- }
- if (_launcher_debug) {
- printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
- (result == JNI_TRUE ? "true" : "false"));
- }
- return result;
-}
-
-#endif /* _ALLBSD_SOURCE && i586 */
-
-/* Dispatch to the platform-specific definition of "server-class" */
-jboolean
-ServerClassMachine(void) {
- jboolean result = JNI_FALSE;
-#if defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
- result = JNI_FALSE;
-#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
- result = JNI_TRUE;
-#elif defined(__sun) && defined(__sparc)
- result = solaris_sparc_ServerClassMachine();
-#elif defined(__sun) && defined(i586)
- result = solaris_i586_ServerClassMachine();
-#elif defined(__linux__) && defined(i586)
- result = linux_i586_ServerClassMachine();
-#elif defined(_ALLBSD_SOURCE) && defined(i586)
- result = bsd_i586_ServerClassMachine();
-#else
- if (_launcher_debug) {
- printf("ServerClassMachine: returns default value of %s\n",
- (result == JNI_TRUE ? "true" : "false"));
- }
-#endif
- return result;
-}
-
-/*
- * Since using the file system as a registry is a bit risky, perform
- * additional sanity checks on the identified directory to validate
- * it as a valid jre/sdk.
- *
- * Return 0 if the tests fail; otherwise return non-zero (true).
- *
- * Note that checking for anything more than the existence of an
- * executable object at bin/java relative to the path being checked
- * will break the regression tests.
- */
-static int
-CheckSanity(char *path, char *dir)
-{
- char buffer[PATH_MAX];
-
- if (strlen(path) + strlen(dir) + 11 > PATH_MAX)
- return (0); /* Silently reject "impossibly" long paths */
-
- (void)strcat(strcat(strcat(strcpy(buffer, path), "/"), dir), "/bin/java");
- return ((access(buffer, X_OK) == 0) ? 1 : 0);
-}
-
-/*
- * Determine if there is an acceptable JRE in the directory dirname.
- * Upon locating the "best" one, return a fully qualified path to
- * it. "Best" is defined as the most advanced JRE meeting the
- * constraints contained in the manifest_info. If no JRE in this
- * directory meets the constraints, return NULL.
- *
- * Note that we don't check for errors in reading the directory
- * (which would be done by checking errno). This is because it
- * doesn't matter if we get an error reading the directory, or
- * we just don't find anything interesting in the directory. We
- * just return NULL in either case.
- *
- * The historical names of j2sdk and j2re were changed to jdk and
- * jre respecively as part of the 1.5 rebranding effort. Since the
- * former names are legacy on Linux, they must be recognized for
- * all time. Fortunately, this is a minor cost.
- */
-static char
-*ProcessDir(manifest_info *info, char *dirname)
-{
- DIR *dirp;
- struct dirent *dp;
- char *best = NULL;
- int offset;
- int best_offset = 0;
- char *ret_str = NULL;
- char buffer[PATH_MAX];
-
- if ((dirp = opendir(dirname)) == NULL)
- return (NULL);
-
- do {
- if ((dp = readdir(dirp)) != NULL) {
- offset = 0;
- if ((strncmp(dp->d_name, "jre", 3) == 0) ||
- (strncmp(dp->d_name, "jdk", 3) == 0))
- offset = 3;
- else if (strncmp(dp->d_name, "j2re", 4) == 0)
- offset = 4;
- else if (strncmp(dp->d_name, "j2sdk", 5) == 0)
- offset = 5;
- if (offset > 0) {
- if ((JLI_AcceptableRelease(dp->d_name + offset,
- info->jre_version)) && CheckSanity(dirname, dp->d_name))
- if ((best == NULL) || (JLI_ExactVersionId(
- dp->d_name + offset, best + best_offset) > 0)) {
- if (best != NULL)
- JLI_MemFree(best);
- best = JLI_StringDup(dp->d_name);
- best_offset = offset;
- }
- }
- }
- } while (dp != NULL);
- (void) closedir(dirp);
- if (best == NULL)
- return (NULL);
- else {
- ret_str = JLI_MemAlloc(strlen(dirname) + strlen(best) + 2);
- ret_str = strcat(strcat(strcpy(ret_str, dirname), "/"), best);
- JLI_MemFree(best);
- return (ret_str);
- }
-}
-
-/*
- * This is the global entry point. It examines the host for the optimal
- * JRE to be used by scanning a set of directories. The set of directories
- * is platform dependent and can be overridden by the environment
- * variable JAVA_VERSION_PATH.
- *
- * This routine itself simply determines the set of appropriate
- * directories before passing control onto ProcessDir().
- */
-char*
-LocateJRE(manifest_info* info)
-{
- char *path;
- char *home;
- char *target = NULL;
- char *dp;
- char *cp;
-
- /*
- * Start by getting JAVA_VERSION_PATH
- */
- if (info->jre_restrict_search)
- path = JLI_StringDup(system_dir);
- else if ((path = getenv("JAVA_VERSION_PATH")) != NULL)
- path = JLI_StringDup(path);
- else
- if ((home = getenv("HOME")) != NULL) {
- path = (char *)JLI_MemAlloc(strlen(home) + strlen(system_dir) +
- strlen(user_dir) + 2);
- path = strcat(strcat(strcat(strcpy(path, home),
- user_dir), ":"), system_dir);
- } else
- path = JLI_StringDup(system_dir);
-
- /*
- * Step through each directory on the path. Terminate the scan with
- * the first directory with an acceptable JRE.
- */
- cp = dp = path;
- while (dp != NULL) {
- cp = strchr(dp, (int)':');
- if (cp != NULL)
- *cp = (char)NULL;
- if ((target = ProcessDir(info, dp)) != NULL)
- break;
- dp = cp;
- if (dp != NULL)
- dp++;
- }
- JLI_MemFree(path);
- return (target);
-}
-
-/*
- * Given a path to a jre to execute, this routine checks if this process
- * is indeed that jre. If not, it exec's that jre.
- *
- * We want to actually check the paths rather than just the version string
- * built into the executable, so that given version specification (and
- * JAVA_VERSION_PATH) will yield the exact same Java environment, regardless
- * of the version of the arbitrary launcher we start with.
- */
-void
-ExecJRE(char *jre, char **argv)
-{
- char wanted[PATH_MAX];
- char *execname;
- char *progname;
-
- /*
- * Resolve the real path to the directory containing the selected JRE.
- */
- if (realpath(jre, wanted) == NULL) {
- fprintf(stderr, "Unable to resolve %s\n", jre);
- exit(1);
- }
-
- /*
- * Resolve the real path to the currently running launcher.
- */
- execname = SetExecname(argv);
- if (execname == NULL) {
- fprintf(stderr, "Unable to resolve current executable\n");
- exit(1);
- }
-
- /*
- * If the path to the selected JRE directory is a match to the initial
- * portion of the path to the currently executing JRE, we have a winner!
- * If so, just return.
- */
- if (strncmp(wanted, execname, strlen(wanted)) == 0)
- return; /* I am the droid you were looking for */
-
- /*
- * If this isn't the selected version, exec the selected version.
- */
-#ifdef JAVA_ARGS /* javac, jar and friends. */
- progname = "java";
-#else /* java, oldjava, javaw and friends */
-#ifdef PROGNAME
- progname = PROGNAME;
-#else
- progname = *argv;
- if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
- progname = s + 1;
- }
-#endif /* PROGNAME */
-#endif /* JAVA_ARGS */
-
- /*
- * This should never happen (because of the selection code in SelectJRE),
- * but check for "impossibly" long path names just because buffer overruns
- * can be so deadly.
- */
- if (strlen(wanted) + strlen(progname) + 6 > PATH_MAX) {
- fprintf(stderr, "Path length exceeds maximum length (PATH_MAX)\n");
- exit(1);
- }
-
- /*
- * Construct the path and exec it.
- */
- (void)strcat(strcat(wanted, "/bin/"), progname);
- argv[0] = progname;
- if (_launcher_debug) {
- int i;
- printf("ReExec Command: %s (%s)\n", wanted, argv[0]);
- printf("ReExec Args:");
- for (i = 1; argv[i] != NULL; i++)
- printf(" %s", argv[i]);
- printf("\n");
- }
- (void)fflush(stdout);
- (void)fflush(stderr);
- execv(wanted, argv);
- perror("execv()");
- fprintf(stderr, "Exec of %s failed\n", wanted);
- exit(1);
-}
-#endif /* ifndef GAMMA */
-
-/*
- * "Borrowed" from Solaris 10 where the unsetenv() function is being added
- * to libc thanks to SUSv3 (Standard Unix Specification, version 3). As
- * such, in the fullness of time this will appear in libc on all relevant
- * Solaris/Linux platforms and maybe even the Windows platform. At that
- * time, this stub can be removed.
- *
- * This implementation removes the environment locking for multithreaded
- * applications. (We don't have access to these mutexes within libc and
- * the launcher isn't multithreaded.) Note that what remains is platform
- * independent, because it only relies on attributes that a POSIX environment
- * defines.
- *
- * Returns 0 on success, -1 on failure.
- *
- * Also removed was the setting of errno. The only value of errno set
- * was EINVAL ("Invalid Argument").
- */
-
-/*
- * s1(environ) is name=value
- * s2(name) is name(not the form of name=value).
- * if names match, return value of 1, else return 0
- */
-static int
-match_noeq(const char *s1, const char *s2)
-{
- while (*s1 == *s2++) {
- if (*s1++ == '=')
- return (1);
- }
- if (*s1 == '=' && s2[-1] == '\0')
- return (1);
- return (0);
-}
-
-/*
- * added for SUSv3 standard
- *
- * Delete entry from environ.
- * Do not free() memory! Other threads may be using it.
- * Keep it around forever.
- */
-static int
-borrowed_unsetenv(const char *name)
-{
- long idx; /* index into environ */
-
- if (name == NULL || *name == '\0' ||
- strchr(name, '=') != NULL) {
- return (-1);
- }
-
- for (idx = 0; environ[idx] != NULL; idx++) {
- if (match_noeq(environ[idx], name))
- break;
- }
- if (environ[idx] == NULL) {
- /* name not found but still a success */
- return (0);
- }
- /* squeeze up one entry */
- do {
- environ[idx] = environ[idx+1];
- } while (environ[++idx] != NULL);
-
- return (0);
-}
-/* --- End of "borrowed" code --- */
-
-/*
- * Wrapper for unsetenv() function.
- */
-int
-UnsetEnv(char *name)
-{
- return(borrowed_unsetenv(name));
-}
-
-/* --- Splash Screen shared library support --- */
-
-static const char* SPLASHSCREEN_SO = "libsplashscreen.so";
-
-static void* hSplashLib = NULL;
-
-void* SplashProcAddress(const char* name) {
- if (!hSplashLib) {
- hSplashLib = dlopen(SPLASHSCREEN_SO, RTLD_LAZY | RTLD_GLOBAL);
- }
- if (hSplashLib) {
- void* sym = dlsym(hSplashLib, name);
- return sym;
- } else {
- return NULL;
- }
-}
-
-void SplashFreeLibrary() {
- if (hSplashLib) {
- dlclose(hSplashLib);
- hSplashLib = NULL;
- }
-}
-
-/*
- * Block current thread and continue execution in a new thread
- */
-int
-ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
- int rslt;
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
- pthread_t tid;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- if (stack_size > 0) {
- pthread_attr_setstacksize(&attr, stack_size);
- }
-
- if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
- void * tmp;
- pthread_join(tid, &tmp);
- rslt = (int)(intptr_t)tmp;
- } else {
- /*
- * Continue execution in current thread if for some reason (e.g. out of
- * memory/LWP) a new thread can't be created. This will likely fail
- * later in continuation as JNI_CreateJavaVM needs to create quite a
- * few new threads, anyway, just give it a try..
- */
- rslt = continuation(args);
- }
-
- pthread_attr_destroy(&attr);
-#else
- thread_t tid;
- long flags = 0;
- if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
- void * tmp;
- thr_join(tid, NULL, &tmp);
- rslt = (int)(intptr_t)tmp;
- } else {
- /* See above. Continue in current thread if thr_create() failed */
- rslt = continuation(args);
- }
-#endif
- return rslt;
-}
-
-/* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
-#define MAX_PID_STR_SZ 20
-
-void SetJavaLauncherPlatformProps() {
- /* Linux only */
-#ifdef __linux__
- const char *substr = "-Dsun.java.launcher.pid=";
- char *pid_prop_str = (char *)JLI_MemAlloc(strlen(substr) + MAX_PID_STR_SZ + 1);
- sprintf(pid_prop_str, "%s%d", substr, getpid());
- AddOption(pid_prop_str, NULL);
-#endif
-}
diff --git a/hotspot/src/os/posix/launcher/java_md.h b/hotspot/src/os/posix/launcher/java_md.h
deleted file mode 100644
index 63c449a2926..00000000000
--- a/hotspot/src/os/posix/launcher/java_md.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- *
- */
-
-#ifndef JAVA_MD_H
-#define JAVA_MD_H
-
-#include
-#include
-#include
-#ifndef GAMMA
-#include "manifest_info.h"
-#endif
-#include "jli_util.h"
-
-#define PATH_SEPARATOR ':'
-#define FILESEP "/"
-#define FILE_SEPARATOR '/'
-#define IS_FILE_SEPARATOR(c) ((c) == '/')
-#ifndef MAXNAMELEN
-#define MAXNAMELEN PATH_MAX
-#endif
-
-#ifdef JAVA_ARGS
-/*
- * ApplicationHome is prepended to each of these entries; the resulting
- * strings are concatenated (separated by PATH_SEPARATOR) and used as the
- * value of -cp option to the launcher.
- */
-#ifndef APP_CLASSPATH
-#define APP_CLASSPATH { "/lib/tools.jar", "/classes" }
-#endif
-#endif
-
-#ifdef HAVE_GETHRTIME
-/*
- * Support for doing cheap, accurate interval timing.
- */
-#include
-#define CounterGet() (gethrtime()/1000)
-#define Counter2Micros(counts) (counts)
-#else
-#define CounterGet() (0)
-#define Counter2Micros(counts) (1)
-#endif /* HAVE_GETHRTIME */
-
-#ifdef _LP64
-#define JLONG_FORMAT "%ld"
-#else
-#define JLONG_FORMAT "%lld"
-#endif
-
-/*
- * Function prototypes.
- */
-#ifndef GAMMA
-char *LocateJRE(manifest_info *info);
-void ExecJRE(char *jre, char **argv);
-#endif
-int UnsetEnv(char *name);
-
-#endif
diff --git a/hotspot/src/os/windows/launcher/java_md.c b/hotspot/src/os/windows/launcher/java_md.c
deleted file mode 100644
index 3e28755009c..00000000000
--- a/hotspot/src/os/windows/launcher/java_md.c
+++ /dev/null
@@ -1,1507 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include "java.h"
-#ifndef GAMMA
-#include "version_comp.h"
-#endif
-
-#define JVM_DLL "jvm.dll"
-#define JAVA_DLL "java.dll"
-#define CRT_DLL "msvcr71.dll"
-
-/*
- * Prototypes.
- */
-static jboolean GetPublicJREHome(char *path, jint pathsize);
-static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
- char *jvmpath, jint jvmpathsize);
-static jboolean GetJREPath(char *path, jint pathsize);
-static void EnsureJreInstallation(const char *jrepath);
-
-/* We supports warmup for UI stack that is performed in parallel
- * to VM initialization.
- * This helps to improve startup of UI application as warmup phase
- * might be long due to initialization of OS or hardware resources.
- * It is not CPU bound and therefore it does not interfere with VM init.
- * Obviously such warmup only has sense for UI apps and therefore it needs
- * to be explicitly requested by passing -Dsun.awt.warmup=true property
- * (this is always the case for plugin/javaws).
- *
- * Implementation launches new thread after VM starts and use it to perform
- * warmup code (platform dependent).
- * This thread is later reused as AWT toolkit thread as graphics toolkit
- * often assume that they are used from the same thread they were launched on.
- *
- * At the moment we only support warmup for D3D. It only possible on windows
- * and only if other flags do not prohibit this (e.g. OpenGL support requested).
- */
-#undef ENABLE_AWT_PRELOAD
-#ifndef JAVA_ARGS /* turn off AWT preloading for javac, jar, etc */
- #ifdef _X86_ /* for now disable AWT preloading for 64bit */
- #define ENABLE_AWT_PRELOAD
- #endif
-#endif
-
-#ifdef ENABLE_AWT_PRELOAD
-/* "AWT was preloaded" flag;
- * Turned on by AWTPreload().
- */
-int awtPreloaded = 0;
-
-/* Calls a function with the name specified.
- * The function must be int(*fn)(void).
- */
-int AWTPreload(const char *funcName);
-/* Stops AWT preloading. */
-void AWTPreloadStop();
-
-/* D3D preloading */
-/* -1: not initialized; 0: OFF, 1: ON */
-int awtPreloadD3D = -1;
-/* Command line parameter to swith D3D preloading on. */
-#define PARAM_PRELOAD_D3D "-Dsun.awt.warmup"
-/* D3D/OpenGL management parameters (may disable D3D preloading) */
-#define PARAM_NODDRAW "-Dsun.java2d.noddraw"
-#define PARAM_D3D "-Dsun.java2d.d3d"
-#define PARAM_OPENGL "-Dsun.java2d.opengl"
-/* funtion in awt.dll (src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp) */
-#define D3D_PRELOAD_FUNC "preloadD3D"
-
-
-/* Extracts value of a parameter with the specified name
- * from command line argument (returns pointer in the argument).
- * Returns NULL if the argument does not contains the parameter.
- * e.g.:
- * GetParamValue("theParam", "theParam=value") returns pointer to "value".
- */
-const char * GetParamValue(const char *paramName, const char *arg) {
- int nameLen = strlen(paramName);
- if (strncmp(paramName, arg, nameLen) == 0) {
- // arg[nameLen] is valid (may contain final NULL)
- if (arg[nameLen] == '=') {
- return arg + nameLen + 1;
- }
- }
- return NULL;
-}
-
-/* Checks if commandline argument contains property specified
- * and analyze it as boolean property (true/false).
- * Returns -1 if the argument does not contain the parameter;
- * Returns 1 if the argument contains the parameter and its value is "true";
- * Returns 0 if the argument contains the parameter and its value is "false".
- */
-int GetBoolParamValue(const char *paramName, const char *arg) {
- const char * paramValue = GetParamValue(paramName, arg);
- if (paramValue != NULL) {
- if (stricmp(paramValue, "true") == 0) {
- return 1;
- }
- if (stricmp(paramValue, "false") == 0) {
- return 0;
- }
- }
- return -1;
-}
-#endif /* ENABLE_AWT_PRELOAD */
-
-
-const char *
-GetArch()
-{
-
-#ifdef _M_AMD64
- return "amd64";
-#elif defined(_M_IA64)
- return "ia64";
-#else
- return "i386";
-#endif
-}
-
-/*
- *
- */
-void
-CreateExecutionEnvironment(int *_argc,
- char ***_argv,
- char jrepath[],
- jint so_jrepath,
- char jvmpath[],
- jint so_jvmpath,
- char **original_argv) {
-#ifndef GAMMA
- char * jvmtype;
-
- /* Find out where the JRE is that we will be using. */
- if (!GetJREPath(jrepath, so_jrepath)) {
- ReportErrorMessage("Error: could not find Java SE Runtime Environment.",
- JNI_TRUE);
- exit(2);
- }
-
- /* Do this before we read jvm.cfg */
- EnsureJreInstallation(jrepath);
-
- /* Find the specified JVM type */
- if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
- ReportErrorMessage("Error: no known VMs. (check for corrupt jvm.cfg file)",
- JNI_TRUE);
- exit(1);
- }
- jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
-
- jvmpath[0] = '\0';
- if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
- char * message=NULL;
- const char * format = "Error: no `%s' JVM at `%s'.";
- message = (char *)JLI_MemAlloc((strlen(format)+strlen(jvmtype)+
- strlen(jvmpath)) * sizeof(char));
- sprintf(message,format, jvmtype, jvmpath);
- ReportErrorMessage(message, JNI_TRUE);
- exit(4);
- }
- /* If we got here, jvmpath has been correctly initialized. */
-
-#else /* ifndef GAMMA */
-
- /*
- * gamma launcher is simpler in that it doesn't handle VM flavors, data
- * model, etc. Assuming everything is set-up correctly
- * all we need to do here is to return correct path names. See also
- * GetJVMPath() and GetApplicationHome().
- */
-
- {
- if (!GetJREPath(jrepath, so_jrepath) ) {
- ReportErrorMessage("Error: could not find Java SE Runtime Environment.",
- JNI_TRUE);
- exit(2);
- }
-
- if (!GetJVMPath(jrepath, NULL, jvmpath, so_jvmpath)) {
- char * message=NULL;
- const char * format = "Error: no JVM at `%s'.";
- message = (char *)JLI_MemAlloc((strlen(format)+
- strlen(jvmpath)) * sizeof(char));
- sprintf(message, format, jvmpath);
- ReportErrorMessage(message, JNI_TRUE);
- exit(4);
- }
- }
-
-#endif /* ifndef GAMMA */
-
-}
-
-
-static jboolean
-LoadMSVCRT()
-{
- // Only do this once
- static int loaded = 0;
- char crtpath[MAXPATHLEN];
-
- if (!loaded) {
- /*
- * The Microsoft C Runtime Library needs to be loaded first. A copy is
- * assumed to be present in the "JRE path" directory. If it is not found
- * there (or "JRE path" fails to resolve), skip the explicit load and let
- * nature take its course, which is likely to be a failure to execute.
- */
- if (GetJREPath(crtpath, MAXPATHLEN)) {
- (void)strcat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */
- if (_launcher_debug) {
- printf("CRT path is %s\n", crtpath);
- }
- if (_access(crtpath, 0) == 0) {
- if (LoadLibrary(crtpath) == 0) {
- ReportErrorMessage2("Error loading: %s", crtpath, JNI_TRUE);
- return JNI_FALSE;
- }
- }
- }
- loaded = 1;
- }
- return JNI_TRUE;
-}
-
-/*
- * The preJVMStart is a function in the jkernel.dll, which
- * performs the final step of synthesizing back the decomposed
- * modules (partial install) to the full JRE. Any tool which
- * uses the JRE must peform this step to ensure the complete synthesis.
- * The EnsureJreInstallation function calls preJVMStart based on
- * the conditions outlined below, noting that the operation
- * will fail silently if any of conditions are not met.
- * NOTE: this call must be made before jvm.dll is loaded, or jvm.cfg
- * is read, since jvm.cfg will be modified by the preJVMStart.
- * 1. Are we on a supported platform.
- * 2. Find the location of the JRE or the Kernel JRE.
- * 3. check existence of JREHOME/lib/bundles
- * 4. check jkernel.dll and invoke the entry-point
- */
-typedef VOID (WINAPI *PREJVMSTART)();
-
-static void
-EnsureJreInstallation(const char* jrepath)
-{
- HINSTANCE handle;
- char tmpbuf[MAXPATHLEN];
- PREJVMSTART PreJVMStart;
- struct stat s;
-
- /* 32 bit windows only please */
- if (strcmp(GetArch(), "i386") != 0 ) {
- if (_launcher_debug) {
- printf("EnsureJreInstallation:unsupported platform\n");
- }
- return;
- }
- /* Does our bundle directory exist ? */
- strcpy(tmpbuf, jrepath);
- strcat(tmpbuf, "\\lib\\bundles");
- if (stat(tmpbuf, &s) != 0) {
- if (_launcher_debug) {
- printf("EnsureJreInstallation:<%s>:not found\n", tmpbuf);
- }
- return;
- }
- /* Does our jkernel dll exist ? */
- strcpy(tmpbuf, jrepath);
- strcat(tmpbuf, "\\bin\\jkernel.dll");
- if (stat(tmpbuf, &s) != 0) {
- if (_launcher_debug) {
- printf("EnsureJreInstallation:<%s>:not found\n", tmpbuf);
- }
- return;
- }
- /* The Microsoft C Runtime Library needs to be loaded first. */
- if (!LoadMSVCRT()) {
- if (_launcher_debug) {
- printf("EnsureJreInstallation:could not load C runtime DLL\n");
- }
- return;
- }
- /* Load the jkernel.dll */
- if ((handle = LoadLibrary(tmpbuf)) == 0) {
- if (_launcher_debug) {
- printf("EnsureJreInstallation:%s:load failed\n", tmpbuf);
- }
- return;
- }
- /* Get the function address */
- PreJVMStart = (PREJVMSTART)GetProcAddress(handle, "preJVMStart");
- if (PreJVMStart == NULL) {
- if (_launcher_debug) {
- printf("EnsureJreInstallation:preJVMStart:function lookup failed\n");
- }
- FreeLibrary(handle);
- return;
- }
- PreJVMStart();
- if (_launcher_debug) {
- printf("EnsureJreInstallation:preJVMStart:called\n");
- }
- FreeLibrary(handle);
- return;
-}
-
-/*
- * Find path to JRE based on .exe's location or registry settings.
- */
-jboolean
-GetJREPath(char *path, jint pathsize)
-{
- char javadll[MAXPATHLEN];
- struct stat s;
-
- if (GetApplicationHome(path, pathsize)) {
- /* Is JRE co-located with the application? */
- sprintf(javadll, "%s\\bin\\" JAVA_DLL, path);
- if (stat(javadll, &s) == 0) {
- goto found;
- }
-
- /* Does this app ship a private JRE in \jre directory? */
- sprintf(javadll, "%s\\jre\\bin\\" JAVA_DLL, path);
- if (stat(javadll, &s) == 0) {
- strcat(path, "\\jre");
- goto found;
- }
- }
-
-#ifndef GAMMA
- /* Look for a public JRE on this machine. */
- if (GetPublicJREHome(path, pathsize)) {
- goto found;
- }
-#endif
-
- fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
- return JNI_FALSE;
-
- found:
- if (_launcher_debug)
- printf("JRE path is %s\n", path);
- return JNI_TRUE;
-}
-
-/*
- * Given a JRE location and a JVM type, construct what the name the
- * JVM shared library will be. Return true, if such a library
- * exists, false otherwise.
- */
-static jboolean
-GetJVMPath(const char *jrepath, const char *jvmtype,
- char *jvmpath, jint jvmpathsize)
-{
- struct stat s;
-
-#ifndef GAMMA
- if (strchr(jvmtype, '/') || strchr(jvmtype, '\\')) {
- sprintf(jvmpath, "%s\\" JVM_DLL, jvmtype);
- } else {
- sprintf(jvmpath, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype);
- }
-#else
- /*
- * For gamma launcher, JVM is either built-in or in the same directory.
- * Either way we return "/jvm.dll" where is the
- * directory where gamma launcher is located.
- */
-
- char *p;
- GetModuleFileName(0, jvmpath, jvmpathsize);
-
- p = strrchr(jvmpath, '\\');
- if (p) {
- /* replace executable name with libjvm.so */
- snprintf(p + 1, jvmpathsize - (p + 1 - jvmpath), "%s", JVM_DLL);
- } else {
- /* this case shouldn't happen */
- snprintf(jvmpath, jvmpathsize, "%s", JVM_DLL);
- }
-#endif /* ifndef GAMMA */
-
- if (stat(jvmpath, &s) == 0) {
- return JNI_TRUE;
- } else {
- return JNI_FALSE;
- }
-}
-
-/*
- * Load a jvm from "jvmpath" and initialize the invocation functions.
- */
-jboolean
-LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
-{
-#ifdef GAMMA
- /* JVM is directly linked with gamma launcher; no Loadlibrary() */
- ifn->CreateJavaVM = JNI_CreateJavaVM;
- ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
- return JNI_TRUE;
-#else
- HINSTANCE handle;
-
- if (_launcher_debug) {
- printf("JVM path is %s\n", jvmpath);
- }
-
- /* The Microsoft C Runtime Library needs to be loaded first. */
- LoadMSVCRT();
-
- /* Load the Java VM DLL */
- if ((handle = LoadLibrary(jvmpath)) == 0) {
- ReportErrorMessage2("Error loading: %s", (char *)jvmpath, JNI_TRUE);
- return JNI_FALSE;
- }
-
- /* Now get the function addresses */
- ifn->CreateJavaVM =
- (void *)GetProcAddress(handle, "JNI_CreateJavaVM");
- ifn->GetDefaultJavaVMInitArgs =
- (void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
- if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
- ReportErrorMessage2("Error: can't find JNI interfaces in: %s",
- (char *)jvmpath, JNI_TRUE);
- return JNI_FALSE;
- }
-
- return JNI_TRUE;
-#endif /* ifndef GAMMA */
-}
-
-/*
- * If app is "c:\foo\bin\javac", then put "c:\foo" into buf.
- */
-jboolean
-GetApplicationHome(char *buf, jint bufsize)
-{
-#ifndef GAMMA
- char *cp;
- GetModuleFileName(0, buf, bufsize);
- *strrchr(buf, '\\') = '\0'; /* remove .exe file name */
- if ((cp = strrchr(buf, '\\')) == 0) {
- /* This happens if the application is in a drive root, and
- * there is no bin directory. */
- buf[0] = '\0';
- return JNI_FALSE;
- }
- *cp = '\0'; /* remove the bin\ part */
- return JNI_TRUE;
-
-#else /* ifndef GAMMA */
-
- char env[MAXPATHLEN + 1];
-
- /* gamma launcher uses ALT_JAVA_HOME environment variable or jdkpath.txt file to find JDK/JRE */
-
- if (getenv("ALT_JAVA_HOME") != NULL) {
- snprintf(buf, bufsize, "%s", getenv("ALT_JAVA_HOME"));
- }
- else {
- char path[MAXPATHLEN + 1];
- char* p;
- int len;
- FILE* fp;
-
- // find the path to the currect executable
- len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
- if (len == 0 || len > MAXPATHLEN) {
- printf("Could not get directory of current executable.");
- return JNI_FALSE;
- }
- // remove last path component ("hotspot.exe")
- p = strrchr(path, '\\');
- if (p == NULL) {
- printf("Could not parse directory of current executable.\n");
- return JNI_FALSE;
- }
- *p = '\0';
-
- // open jdkpath.txt and read JAVA_HOME from it
- if (strlen(path) + strlen("\\jdkpath.txt") + 1 >= MAXPATHLEN) {
- printf("Path too long: %s\n", path);
- return JNI_FALSE;
- }
- strcat(path, "\\jdkpath.txt");
- fp = fopen(path, "r");
- if (fp == NULL) {
- printf("Could not open file %s to get path to JDK.\n", path);
- return JNI_FALSE;
- }
-
- if (fgets(buf, bufsize, fp) == NULL) {
- printf("Could not read from file %s to get path to JDK.\n", path);
- fclose(fp);
- return JNI_FALSE;
- }
- // trim the buffer
- p = buf + strlen(buf) - 1;
- while(isspace(*p)) {
- *p = '\0';
- p--;
- }
- fclose(fp);
- }
-
- _snprintf(env, MAXPATHLEN, "JAVA_HOME=%s", buf);
- _putenv(env);
-
- return JNI_TRUE;
-#endif /* ifndef GAMMA */
-}
-
-#ifdef JAVAW
-__declspec(dllimport) char **__initenv;
-
-int WINAPI
-WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
-{
- int ret;
-
- __initenv = _environ;
- ret = main(__argc, __argv);
-
- return ret;
-}
-#endif
-
-#ifndef GAMMA
-
-/*
- * Helpers to look in the registry for a public JRE.
- */
- /* Same for 1.5.0, 1.5.1, 1.5.2 etc. */
-#define DOTRELEASE JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
-#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment"
-
-static jboolean
-GetStringFromRegistry(HKEY key, const char *name, char *buf, jint bufsize)
-{
- DWORD type, size;
-
- if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0
- && type == REG_SZ
- && (size < (unsigned int)bufsize)) {
- if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0) {
- return JNI_TRUE;
- }
- }
- return JNI_FALSE;
-}
-
-static jboolean
-GetPublicJREHome(char *buf, jint bufsize)
-{
- HKEY key, subkey;
- char version[MAXPATHLEN];
-
- /*
- * Note: There is a very similar implementation of the following
- * registry reading code in the Windows java control panel (javacp.cpl).
- * If there are bugs here, a similar bug probably exists there. Hence,
- * changes here require inspection there.
- */
-
- /* Find the current version of the JRE */
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) {
- fprintf(stderr, "Error opening registry key '" JRE_KEY "'\n");
- return JNI_FALSE;
- }
-
- if (!GetStringFromRegistry(key, "CurrentVersion",
- version, sizeof(version))) {
- fprintf(stderr, "Failed reading value of registry key:\n\t"
- JRE_KEY "\\CurrentVersion\n");
- RegCloseKey(key);
- return JNI_FALSE;
- }
-
- if (strcmp(version, DOTRELEASE) != 0) {
- fprintf(stderr, "Registry key '" JRE_KEY "\\CurrentVersion'\nhas "
- "value '%s', but '" DOTRELEASE "' is required.\n", version);
- RegCloseKey(key);
- return JNI_FALSE;
- }
-
- /* Find directory where the current version is installed. */
- if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) {
- fprintf(stderr, "Error opening registry key '"
- JRE_KEY "\\%s'\n", version);
- RegCloseKey(key);
- return JNI_FALSE;
- }
-
- if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) {
- fprintf(stderr, "Failed reading value of registry key:\n\t"
- JRE_KEY "\\%s\\JavaHome\n", version);
- RegCloseKey(key);
- RegCloseKey(subkey);
- return JNI_FALSE;
- }
-
- if (_launcher_debug) {
- char micro[MAXPATHLEN];
- if (!GetStringFromRegistry(subkey, "MicroVersion", micro,
- sizeof(micro))) {
- printf("Warning: Can't read MicroVersion\n");
- micro[0] = '\0';
- }
- printf("Version major.minor.micro = %s.%s\n", version, micro);
- }
-
- RegCloseKey(key);
- RegCloseKey(subkey);
- return JNI_TRUE;
-}
-
-#endif /* ifndef GAMMA */
-
-/*
- * Support for doing cheap, accurate interval timing.
- */
-static jboolean counterAvailable = JNI_FALSE;
-static jboolean counterInitialized = JNI_FALSE;
-static LARGE_INTEGER counterFrequency;
-
-jlong CounterGet()
-{
- LARGE_INTEGER count;
-
- if (!counterInitialized) {
- counterAvailable = QueryPerformanceFrequency(&counterFrequency);
- counterInitialized = JNI_TRUE;
- }
- if (!counterAvailable) {
- return 0;
- }
- QueryPerformanceCounter(&count);
- return (jlong)(count.QuadPart);
-}
-
-jlong Counter2Micros(jlong counts)
-{
- if (!counterAvailable || !counterInitialized) {
- return 0;
- }
- return (counts * 1000 * 1000)/counterFrequency.QuadPart;
-}
-
-void ReportErrorMessage(char * message, jboolean always) {
-#ifdef JAVAW
- if (message != NULL) {
- MessageBox(NULL, message, "Java Virtual Machine Launcher",
- (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
- }
-#else
- if (always) {
- fprintf(stderr, "%s\n", message);
- }
-#endif
-}
-
-void ReportErrorMessage2(char * format, char * string, jboolean always) {
- /*
- * The format argument must be a printf format string with one %s
- * argument, which is passed the string argument.
- */
-#ifdef JAVAW
- size_t size;
- char * message;
- size = strlen(format) + strlen(string);
- message = (char*)JLI_MemAlloc(size*sizeof(char));
- sprintf(message, (const char *)format, string);
-
- if (message != NULL) {
- MessageBox(NULL, message, "Java Virtual Machine Launcher",
- (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
- JLI_MemFree(message);
- }
-#else
- if (always) {
- fprintf(stderr, (const char *)format, string);
- fprintf(stderr, "\n");
- }
-#endif
-}
-
-/*
- * As ReportErrorMessage2 (above) except the system message (if any)
- * associated with this error is written to a second %s format specifier
- * in the format argument.
- */
-void ReportSysErrorMessage2(char * format, char * string, jboolean always) {
- int save_errno = errno;
- DWORD errval;
- int freeit = 0;
- char *errtext = NULL;
-
- if ((errval = GetLastError()) != 0) { /* Platform SDK / DOS Error */
- int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
- FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER,
- NULL, errval, 0, (LPTSTR)&errtext, 0, NULL);
- if (errtext == NULL || n == 0) { /* Paranoia check */
- errtext = "";
- n = 0;
- } else {
- freeit = 1;
- if (n > 2) { /* Drop final CR, LF */
- if (errtext[n - 1] == '\n') n--;
- if (errtext[n - 1] == '\r') n--;
- errtext[n] = '\0';
- }
- }
- } else /* C runtime error that has no corresponding DOS error code */
- errtext = strerror(save_errno);
-
-#ifdef JAVAW
- {
- size_t size;
- char * message;
- size = strlen(format) + strlen(string) + strlen(errtext);
- message = (char*)JLI_MemAlloc(size*sizeof(char));
- sprintf(message, (const char *)format, string, errtext);
-
- if (message != NULL) {
- MessageBox(NULL, message, "Java Virtual Machine Launcher",
- (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
- JLI_MemFree(message);
- }
- }
-#else
- if (always) {
- fprintf(stderr, (const char *)format, string, errtext);
- fprintf(stderr, "\n");
- }
-#endif
- if (freeit)
- (void)LocalFree((HLOCAL)errtext);
-}
-
-void ReportExceptionDescription(JNIEnv * env) {
-#ifdef JAVAW
- /*
- * This code should be replaced by code which opens a window with
- * the exception detail message.
- */
- (*env)->ExceptionDescribe(env);
-#else
- (*env)->ExceptionDescribe(env);
-#endif
-}
-
-
-/*
- * Return JNI_TRUE for an option string that has no effect but should
- * _not_ be passed on to the vm; return JNI_FALSE otherwise. On
- * windows, there are no options that should be screened in this
- * manner.
- */
-jboolean RemovableMachineDependentOption(char * option) {
-#ifdef ENABLE_AWT_PRELOAD
- if (awtPreloadD3D < 0) {
- /* Tests the command line parameter only if not set yet. */
- if (GetBoolParamValue(PARAM_PRELOAD_D3D, option) == 1) {
- awtPreloadD3D = 1;
- }
- }
- if (awtPreloadD3D != 0) {
- /* Don't test the command line parameters if already disabled. */
- if (GetBoolParamValue(PARAM_NODDRAW, option) == 1
- || GetBoolParamValue(PARAM_D3D, option) == 0
- || GetBoolParamValue(PARAM_OPENGL, option) == 1)
- {
- awtPreloadD3D = 0;
- }
- }
-#endif /* ENABLE_AWT_PRELOAD */
-
- return JNI_FALSE;
-}
-
-void PrintMachineDependentOptions() {
- return;
-}
-
-#ifndef GAMMA
-
-jboolean
-ServerClassMachine() {
- jboolean result = JNI_FALSE;
-#if defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
- result = JNI_FALSE;
-#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
- result = JNI_TRUE;
-#endif
- return result;
-}
-
-/*
- * Determine if there is an acceptable JRE in the registry directory top_key.
- * Upon locating the "best" one, return a fully qualified path to it.
- * "Best" is defined as the most advanced JRE meeting the constraints
- * contained in the manifest_info. If no JRE in this directory meets the
- * constraints, return NULL.
- *
- * It doesn't matter if we get an error reading the registry, or we just
- * don't find anything interesting in the directory. We just return NULL
- * in either case.
- */
-static char *
-ProcessDir(manifest_info* info, HKEY top_key) {
- DWORD index = 0;
- HKEY ver_key;
- char name[MAXNAMELEN];
- int len;
- char *best = NULL;
-
- /*
- * Enumerate "/SOFTWARE/JavaSoft/Java Runtime Environment"
- * searching for the best available version.
- */
- while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) {
- index++;
- if (JLI_AcceptableRelease(name, info->jre_version))
- if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) {
- if (best != NULL)
- JLI_MemFree(best);
- best = JLI_StringDup(name);
- }
- }
-
- /*
- * Extract "JavaHome" from the "best" registry directory and return
- * that path. If no appropriate version was located, or there is an
- * error in extracting the "JavaHome" string, return null.
- */
- if (best == NULL)
- return (NULL);
- else {
- if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key)
- != ERROR_SUCCESS) {
- JLI_MemFree(best);
- if (ver_key != NULL)
- RegCloseKey(ver_key);
- return (NULL);
- }
- JLI_MemFree(best);
- len = MAXNAMELEN;
- if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len)
- != ERROR_SUCCESS) {
- if (ver_key != NULL)
- RegCloseKey(ver_key);
- return (NULL);
- }
- if (ver_key != NULL)
- RegCloseKey(ver_key);
- return (JLI_StringDup(name));
- }
-}
-
-/*
- * This is the global entry point. It examines the host for the optimal
- * JRE to be used by scanning a set of registry entries. This set of entries
- * is hardwired on Windows as "Software\JavaSoft\Java Runtime Environment"
- * under the set of roots "{ HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }".
- *
- * This routine simply opens each of these registry directories before passing
- * control onto ProcessDir().
- */
-char *
-LocateJRE(manifest_info* info) {
- HKEY key = NULL;
- char *path;
- int key_index;
- HKEY root_keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
-
- for (key_index = 0; key_index <= 1; key_index++) {
- if (RegOpenKeyEx(root_keys[key_index], JRE_KEY, 0, KEY_READ, &key)
- == ERROR_SUCCESS)
- if ((path = ProcessDir(info, key)) != NULL) {
- if (key != NULL)
- RegCloseKey(key);
- return (path);
- }
- if (key != NULL)
- RegCloseKey(key);
- }
- return NULL;
-}
-
-
-/*
- * Local helper routine to isolate a single token (option or argument)
- * from the command line.
- *
- * This routine accepts a pointer to a character pointer. The first
- * token (as defined by MSDN command-line argument syntax) is isolated
- * from that string.
- *
- * Upon return, the input character pointer pointed to by the parameter s
- * is updated to point to the remainding, unscanned, portion of the string,
- * or to a null character if the entire string has been consummed.
- *
- * This function returns a pointer to a null-terminated string which
- * contains the isolated first token, or to the null character if no
- * token could be isolated.
- *
- * Note the side effect of modifying the input string s by the insertion
- * of a null character, making it two strings.
- *
- * See "Parsing C Command-Line Arguments" in the MSDN Library for the
- * parsing rule details. The rule summary from that specification is:
- *
- * * Arguments are delimited by white space, which is either a space or a tab.
- *
- * * A string surrounded by double quotation marks is interpreted as a single
- * argument, regardless of white space contained within. A quoted string can
- * be embedded in an argument. Note that the caret (^) is not recognized as
- * an escape character or delimiter.
- *
- * * A double quotation mark preceded by a backslash, \", is interpreted as a
- * literal double quotation mark (").
- *
- * * Backslashes are interpreted literally, unless they immediately precede a
- * double quotation mark.
- *
- * * If an even number of backslashes is followed by a double quotation mark,
- * then one backslash (\) is placed in the argv array for every pair of
- * backslashes (\\), and the double quotation mark (") is interpreted as a
- * string delimiter.
- *
- * * If an odd number of backslashes is followed by a double quotation mark,
- * then one backslash (\) is placed in the argv array for every pair of
- * backslashes (\\) and the double quotation mark is interpreted as an
- * escape sequence by the remaining backslash, causing a literal double
- * quotation mark (") to be placed in argv.
- */
-static char*
-nextarg(char** s) {
- char *p = *s;
- char *head;
- int slashes = 0;
- int inquote = 0;
-
- /*
- * Strip leading whitespace, which MSDN defines as only space or tab.
- * (Hence, no locale specific "isspace" here.)
- */
- while (*p != (char)0 && (*p == ' ' || *p == '\t'))
- p++;
- head = p; /* Save the start of the token to return */
-
- /*
- * Isolate a token from the command line.
- */
- while (*p != (char)0 && (inquote || !(*p == ' ' || *p == '\t'))) {
- if (*p == '\\' && *(p+1) == '"' && slashes % 2 == 0)
- p++;
- else if (*p == '"')
- inquote = !inquote;
- slashes = (*p++ == '\\') ? slashes + 1 : 0;
- }
-
- /*
- * If the token isolated isn't already terminated in a "char zero",
- * then replace the whitespace character with one and move to the
- * next character.
- */
- if (*p != (char)0)
- *p++ = (char)0;
-
- /*
- * Update the parameter to point to the head of the remaining string
- * reflecting the command line and return a pointer to the leading
- * token which was isolated from the command line.
- */
- *s = p;
- return (head);
-}
-
-/*
- * Local helper routine to return a string equivalent to the input string
- * s, but with quotes removed so the result is a string as would be found
- * in argv[]. The returned string should be freed by a call to JLI_MemFree().
- *
- * The rules for quoting (and escaped quotes) are:
- *
- * 1 A double quotation mark preceded by a backslash, \", is interpreted as a
- * literal double quotation mark (").
- *
- * 2 Backslashes are interpreted literally, unless they immediately precede a
- * double quotation mark.
- *
- * 3 If an even number of backslashes is followed by a double quotation mark,
- * then one backslash (\) is placed in the argv array for every pair of
- * backslashes (\\), and the double quotation mark (") is interpreted as a
- * string delimiter.
- *
- * 4 If an odd number of backslashes is followed by a double quotation mark,
- * then one backslash (\) is placed in the argv array for every pair of
- * backslashes (\\) and the double quotation mark is interpreted as an
- * escape sequence by the remaining backslash, causing a literal double
- * quotation mark (") to be placed in argv.
- */
-static char*
-unquote(const char *s) {
- const char *p = s; /* Pointer to the tail of the original string */
- char *un = (char*)JLI_MemAlloc(strlen(s) + 1); /* Ptr to unquoted string */
- char *pun = un; /* Pointer to the tail of the unquoted string */
-
- while (*p != '\0') {
- if (*p == '"') {
- p++;
- } else if (*p == '\\') {
- const char *q = p + strspn(p,"\\");
- if (*q == '"')
- do {
- *pun++ = '\\';
- p += 2;
- } while (*p == '\\' && p < q);
- else
- while (p < q)
- *pun++ = *p++;
- } else {
- *pun++ = *p++;
- }
- }
- *pun = '\0';
- return un;
-}
-
-/*
- * Given a path to a jre to execute, this routine checks if this process
- * is indeed that jre. If not, it exec's that jre.
- *
- * We want to actually check the paths rather than just the version string
- * built into the executable, so that given version specification will yield
- * the exact same Java environment, regardless of the version of the arbitrary
- * launcher we start with.
- */
-void
-ExecJRE(char *jre, char **argv) {
- int len;
- char *progname;
- char path[MAXPATHLEN + 1];
-
- /*
- * Determine the executable we are building (or in the rare case, running).
- */
-#ifdef JAVA_ARGS /* javac, jar and friends. */
- progname = "java";
-#else /* java, oldjava, javaw and friends */
-#ifdef PROGNAME
- progname = PROGNAME;
-#else
- {
- char *s;
- progname = *argv;
- if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
- progname = s + 1;
- }
- }
-#endif /* PROGNAME */
-#endif /* JAVA_ARGS */
-
- /*
- * Resolve the real path to the currently running launcher.
- */
- len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
- if (len == 0 || len > MAXPATHLEN) {
- ReportSysErrorMessage2(
- "Unable to resolve path to current %s executable: %s",
- progname, JNI_TRUE);
- exit(1);
- }
-
- if (_launcher_debug) {
- printf("ExecJRE: old: %s\n", path);
- printf("ExecJRE: new: %s\n", jre);
- }
-
- /*
- * If the path to the selected JRE directory is a match to the initial
- * portion of the path to the currently executing JRE, we have a winner!
- * If so, just return. (strnicmp() is the Windows equiv. of strncasecmp().)
- */
- if (strnicmp(jre, path, strlen(jre)) == 0)
- return; /* I am the droid you were looking for */
-
- /*
- * If this isn't the selected version, exec the selected version.
- */
- (void)strcat(strcat(strcpy(path, jre), "\\bin\\"), progname);
- (void)strcat(path, ".exe");
-
- /*
- * Although Windows has an execv() entrypoint, it doesn't actually
- * overlay a process: it can only create a new process and terminate
- * the old process. Therefore, any processes waiting on the initial
- * process wake up and they shouldn't. Hence, a chain of pseudo-zombie
- * processes must be retained to maintain the proper wait semantics.
- * Fortunately the image size of the launcher isn't too large at this
- * time.
- *
- * If it weren't for this semantic flaw, the code below would be ...
- *
- * execv(path, argv);
- * ReportErrorMessage2("Exec of %s failed\n", path, JNI_TRUE);
- * exit(1);
- *
- * The incorrect exec semantics could be addressed by:
- *
- * exit((int)spawnv(_P_WAIT, path, argv));
- *
- * Unfortunately, a bug in Windows spawn/exec impementation prevents
- * this from completely working. All the Windows POSIX process creation
- * interfaces are implemented as wrappers around the native Windows
- * function CreateProcess(). CreateProcess() takes a single string
- * to specify command line options and arguments, so the POSIX routine
- * wrappers build a single string from the argv[] array and in the
- * process, any quoting information is lost.
- *
- * The solution to this to get the original command line, to process it
- * to remove the new multiple JRE options (if any) as was done for argv
- * in the common SelectVersion() routine and finally to pass it directly
- * to the native CreateProcess() Windows process control interface.
- */
- {
- char *cmdline;
- char *p;
- char *np;
- char *ocl;
- char *ccl;
- char *unquoted;
- DWORD exitCode;
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
-
- /*
- * The following code block gets and processes the original command
- * line, replacing the argv[0] equivalent in the command line with
- * the path to the new executable and removing the appropriate
- * Multiple JRE support options. Note that similar logic exists
- * in the platform independent SelectVersion routine, but is
- * replicated here due to the syntax of CreateProcess().
- *
- * The magic "+ 4" characters added to the command line length are
- * 2 possible quotes around the path (argv[0]), a space after the
- * path and a terminating null character.
- */
- ocl = GetCommandLine();
- np = ccl = JLI_StringDup(ocl);
- p = nextarg(&np); /* Discard argv[0] */
- cmdline = (char *)JLI_MemAlloc(strlen(path) + strlen(np) + 4);
- if (strchr(path, (int)' ') == NULL && strchr(path, (int)'\t') == NULL)
- cmdline = strcpy(cmdline, path);
- else
- cmdline = strcat(strcat(strcpy(cmdline, "\""), path), "\"");
-
- while (*np != (char)0) { /* While more command-line */
- p = nextarg(&np);
- if (*p != (char)0) { /* If a token was isolated */
- unquoted = unquote(p);
- if (*unquoted == '-') { /* Looks like an option */
- if (strcmp(unquoted, "-classpath") == 0 ||
- strcmp(unquoted, "-cp") == 0) { /* Unique cp syntax */
- cmdline = strcat(strcat(cmdline, " "), p);
- p = nextarg(&np);
- if (*p != (char)0) /* If a token was isolated */
- cmdline = strcat(strcat(cmdline, " "), p);
- } else if (strncmp(unquoted, "-version:", 9) != 0 &&
- strcmp(unquoted, "-jre-restrict-search") != 0 &&
- strcmp(unquoted, "-no-jre-restrict-search") != 0) {
- cmdline = strcat(strcat(cmdline, " "), p);
- }
- } else { /* End of options */
- cmdline = strcat(strcat(cmdline, " "), p);
- cmdline = strcat(strcat(cmdline, " "), np);
- JLI_MemFree((void *)unquoted);
- break;
- }
- JLI_MemFree((void *)unquoted);
- }
- }
- JLI_MemFree((void *)ccl);
-
- if (_launcher_debug) {
- np = ccl = JLI_StringDup(cmdline);
- p = nextarg(&np);
- printf("ReExec Command: %s (%s)\n", path, p);
- printf("ReExec Args: %s\n", np);
- JLI_MemFree((void *)ccl);
- }
- (void)fflush(stdout);
- (void)fflush(stderr);
-
- /*
- * The following code is modeled after a model presented in the
- * Microsoft Technical Article "Moving Unix Applications to
- * Windows NT" (March 6, 1994) and "Creating Processes" on MSDN
- * (Februrary 2005). It approximates UNIX spawn semantics with
- * the parent waiting for termination of the child.
- */
- memset(&si, 0, sizeof(si));
- si.cb =sizeof(STARTUPINFO);
- memset(&pi, 0, sizeof(pi));
-
- if (!CreateProcess((LPCTSTR)path, /* executable name */
- (LPTSTR)cmdline, /* command line */
- (LPSECURITY_ATTRIBUTES)NULL, /* process security attr. */
- (LPSECURITY_ATTRIBUTES)NULL, /* thread security attr. */
- (BOOL)TRUE, /* inherits system handles */
- (DWORD)0, /* creation flags */
- (LPVOID)NULL, /* environment block */
- (LPCTSTR)NULL, /* current directory */
- (LPSTARTUPINFO)&si, /* (in) startup information */
- (LPPROCESS_INFORMATION)&pi)) { /* (out) process information */
- ReportSysErrorMessage2("CreateProcess(%s, ...) failed: %s",
- path, JNI_TRUE);
- exit(1);
- }
-
- if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_FAILED) {
- if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE)
- exitCode = 1;
- } else {
- ReportErrorMessage("WaitForSingleObject() failed.", JNI_TRUE);
- exitCode = 1;
- }
-
- CloseHandle(pi.hThread);
- CloseHandle(pi.hProcess);
-
- exit(exitCode);
- }
-
-}
-
-#endif /* ifndef GAMMA */
-
-
-/*
- * Wrapper for platform dependent unsetenv function.
- */
-int
-UnsetEnv(char *name)
-{
- int ret;
- char *buf = JLI_MemAlloc(strlen(name) + 2);
- buf = strcat(strcpy(buf, name), "=");
- ret = _putenv(buf);
- JLI_MemFree(buf);
- return (ret);
-}
-
-/* --- Splash Screen shared library support --- */
-
-static const char* SPLASHSCREEN_SO = "\\bin\\splashscreen.dll";
-
-static HMODULE hSplashLib = NULL;
-
-void* SplashProcAddress(const char* name) {
- char libraryPath[MAXPATHLEN]; /* some extra space for strcat'ing SPLASHSCREEN_SO */
-
- if (!GetJREPath(libraryPath, MAXPATHLEN)) {
- return NULL;
- }
- if (strlen(libraryPath)+strlen(SPLASHSCREEN_SO) >= MAXPATHLEN) {
- return NULL;
- }
- strcat(libraryPath, SPLASHSCREEN_SO);
-
- if (!hSplashLib) {
- hSplashLib = LoadLibrary(libraryPath);
- }
- if (hSplashLib) {
- return GetProcAddress(hSplashLib, name);
- } else {
- return NULL;
- }
-}
-
-void SplashFreeLibrary() {
- if (hSplashLib) {
- FreeLibrary(hSplashLib);
- hSplashLib = NULL;
- }
-}
-
-/*
- * Block current thread and continue execution in a new thread
- */
-int
-ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
- int rslt = 0;
- unsigned thread_id;
-
-#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
-#define STACK_SIZE_PARAM_IS_A_RESERVATION (0x10000)
-#endif
-
- /*
- * STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not
- * supported on older version of Windows. Try first with the flag; and
- * if that fails try again without the flag. See MSDN document or HotSpot
- * source (os_win32.cpp) for details.
- */
- HANDLE thread_handle =
- (HANDLE)_beginthreadex(NULL,
- (unsigned)stack_size,
- continuation,
- args,
- STACK_SIZE_PARAM_IS_A_RESERVATION,
- &thread_id);
- if (thread_handle == NULL) {
- thread_handle =
- (HANDLE)_beginthreadex(NULL,
- (unsigned)stack_size,
- continuation,
- args,
- 0,
- &thread_id);
- }
-
- /* AWT preloading (AFTER main thread start) */
-#ifdef ENABLE_AWT_PRELOAD
- /* D3D preloading */
- if (awtPreloadD3D != 0) {
- char *envValue;
- /* D3D routines checks env.var J2D_D3D if no appropriate
- * command line params was specified
- */
- envValue = getenv("J2D_D3D");
- if (envValue != NULL && stricmp(envValue, "false") == 0) {
- awtPreloadD3D = 0;
- }
- /* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */
- envValue = getenv("J2D_D3D_PRELOAD");
- if (envValue != NULL && stricmp(envValue, "false") == 0) {
- awtPreloadD3D = 0;
- }
- if (awtPreloadD3D < 0) {
- /* If awtPreloadD3D is still undefined (-1), test
- * if it is turned on by J2D_D3D_PRELOAD env.var.
- * By default it's turned OFF.
- */
- awtPreloadD3D = 0;
- if (envValue != NULL && stricmp(envValue, "true") == 0) {
- awtPreloadD3D = 1;
- }
- }
- }
- if (awtPreloadD3D) {
- AWTPreload(D3D_PRELOAD_FUNC);
- }
-#endif /* ENABLE_AWT_PRELOAD */
-
- if (thread_handle) {
- WaitForSingleObject(thread_handle, INFINITE);
- GetExitCodeThread(thread_handle, &rslt);
- CloseHandle(thread_handle);
- } else {
- rslt = continuation(args);
- }
-
-#ifdef ENABLE_AWT_PRELOAD
- if (awtPreloaded) {
- AWTPreloadStop();
- }
-#endif /* ENABLE_AWT_PRELOAD */
-
- return rslt;
-}
-
-/* Linux only, empty on windows. */
-void SetJavaLauncherPlatformProps() {}
-
-
-//==============================
-// AWT preloading
-#ifdef ENABLE_AWT_PRELOAD
-
-typedef int FnPreloadStart(void);
-typedef void FnPreloadStop(void);
-static FnPreloadStop *fnPreloadStop = NULL;
-static HMODULE hPreloadAwt = NULL;
-
-/*
- * Starts AWT preloading
- */
-int AWTPreload(const char *funcName)
-{
- int result = -1;
-
- // load AWT library once (if several preload function should be called)
- if (hPreloadAwt == NULL) {
- // awt.dll is not loaded yet
- char libraryPath[MAXPATHLEN];
- int jrePathLen = 0;
- HMODULE hJava = NULL;
- HMODULE hVerify = NULL;
-
- while (1) {
- // awt.dll depends on jvm.dll & java.dll;
- // jvm.dll is already loaded, so we need only java.dll;
- // java.dll depends on MSVCRT lib & verify.dll.
- if (!GetJREPath(libraryPath, MAXPATHLEN)) {
- break;
- }
-
- // save path length
- jrePathLen = strlen(libraryPath);
-
- // load msvcrt 1st
- LoadMSVCRT();
-
- // load verify.dll
- strcat(libraryPath, "\\bin\\verify.dll");
- hVerify = LoadLibrary(libraryPath);
- if (hVerify == NULL) {
- break;
- }
-
- // restore jrePath
- libraryPath[jrePathLen] = 0;
- // load java.dll
- strcat(libraryPath, "\\bin\\" JAVA_DLL);
- hJava = LoadLibrary(libraryPath);
- if (hJava == NULL) {
- break;
- }
-
- // restore jrePath
- libraryPath[jrePathLen] = 0;
- // load awt.dll
- strcat(libraryPath, "\\bin\\awt.dll");
- hPreloadAwt = LoadLibrary(libraryPath);
- if (hPreloadAwt == NULL) {
- break;
- }
-
- // get "preloadStop" func ptr
- fnPreloadStop = (FnPreloadStop *)GetProcAddress(hPreloadAwt, "preloadStop");
-
- break;
- }
- }
-
- if (hPreloadAwt != NULL) {
- FnPreloadStart *fnInit = (FnPreloadStart *)GetProcAddress(hPreloadAwt, funcName);
- if (fnInit != NULL) {
- // don't forget to stop preloading
- awtPreloaded = 1;
-
- result = fnInit();
- }
- }
-
- return result;
-}
-
-/*
- * Terminates AWT preloading
- */
-void AWTPreloadStop() {
- if (fnPreloadStop != NULL) {
- fnPreloadStop();
- }
-}
-
-#endif /* ENABLE_AWT_PRELOAD */
diff --git a/hotspot/src/os/windows/launcher/java_md.h b/hotspot/src/os/windows/launcher/java_md.h
deleted file mode 100644
index 763e2457644..00000000000
--- a/hotspot/src/os/windows/launcher/java_md.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- *
- */
-
-#ifndef JAVA_MD_H
-#define JAVA_MD_H
-
-#include
-#include
-#include
-#ifndef GAMMA
-#include "manifest_info.h"
-#endif
-#include "jli_util.h"
-
-#ifdef GAMMA
-#define stricmp _stricmp
-#define strnicmp _strnicmp
-#define snprintf _snprintf
-#define strdup _strdup
-#endif
-
-#define PATH_SEPARATOR ';'
-#define FILESEP "\\"
-#define FILE_SEPARATOR '\\'
-#define IS_FILE_SEPARATOR(c) ((c) == '\\' || (c) == '/')
-#define MAXPATHLEN MAX_PATH
-#define MAXNAMELEN MAX_PATH
-
-#ifdef JAVA_ARGS
-/*
- * ApplicationHome is prepended to each of these entries; the resulting
- * strings are concatenated (separated by PATH_SEPARATOR) and used as the
- * value of -cp option to the launcher.
- */
-#ifndef APP_CLASSPATH
-#define APP_CLASSPATH { "\\lib\\tools.jar", "\\classes" }
-#endif
-#endif
-
-/*
- * Support for doing cheap, accurate interval timing.
- */
-extern jlong CounterGet(void);
-extern jlong Counter2Micros(jlong counts);
-
-#ifdef JAVAW
-#define main _main
-extern int _main(int argc, char **argv);
-#endif
-
-#define JLONG_FORMAT "%I64d"
-
-/*
- * Function prototypes.
- */
-#ifndef GAMMA
-char *LocateJRE(manifest_info *info);
-void ExecJRE(char *jre, char **argv);
-#endif
-int UnsetEnv(char *name);
-
-#endif
diff --git a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java
index 953967fccd4..f9283886a87 100644
--- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java
+++ b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java
@@ -65,6 +65,7 @@ class BuildConfig {
String sourceBase = getFieldString(null, "SourceBase");
String buildSpace = getFieldString(null, "BuildSpace");
String outDir = buildBase;
+ String jdkTargetRoot = getFieldString(null, "JdkTargetRoot");
put("Id", flavourBuild);
put("OutputDir", outDir);
@@ -72,6 +73,7 @@ class BuildConfig {
put("BuildBase", buildBase);
put("BuildSpace", buildSpace);
put("OutputDll", outDir + Util.sep + outDll);
+ put("JdkTargetRoot", jdkTargetRoot);
context = new String [] {flavourBuild, flavour, build, null};
}
diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
index 137abdc30e9..8d094d30108 100644
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
+++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
@@ -98,11 +98,6 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
tagV(cfg.getV("LinkerFlags"));
endTag();
- startTag("PostBuildEvent");
- tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription"));
- tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n")));
- endTag();
-
startTag("PreLinkEvent");
tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription"));
tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n")));
@@ -141,7 +136,9 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
for (BuildConfig cfg : allConfigs) {
startTag(cfg, "PropertyGroup");
- tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe");
+ tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe");
+ tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) -Dsun.java.launcher=gamma");
+ tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot"));
endTag();
}
diff --git a/hotspot/src/share/tools/launcher/java.c b/hotspot/src/share/tools/launcher/java.c
deleted file mode 100644
index 63f11d77c86..00000000000
--- a/hotspot/src/share/tools/launcher/java.c
+++ /dev/null
@@ -1,2080 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- *
- */
-
-/*
- * Gamma (Hotspot internal engineering test) launcher based on 6.0u22 JDK,
- * search "GAMMA" for gamma specific changes.
- *
- * GAMMA: gamma launcher is much simpler than regular java launcher in that
- * JVM is either statically linked in or it is installed in the
- * same directory where the launcher exists, so we don't have to
- * worry about choosing the right JVM based on command line flag, jar
- * file and/or ergonomics. Intead of removing unused logic from source
- * they are commented out with #ifndef GAMMA, hopefully it'll be easier
- * to maintain this file in sync with regular JDK launcher.
- */
-
-/*
- * Shared source for 'java' command line tool.
- *
- * If JAVA_ARGS is defined, then acts as a launcher for applications. For
- * instance, the JDK command line tools such as javac and javadoc (see
- * makefiles for more details) are built with this program. Any arguments
- * prefixed with '-J' will be passed directly to the 'java' command.
- */
-
-#ifdef GAMMA
-# ifdef JAVA_ARGS
-# error Do NOT define JAVA_ARGS when building gamma launcher
-# endif
-# if !defined(LINK_INTO_AOUT) && !defined(LINK_INTO_LIBJVM)
-# error Either LINK_INTO_AOUT or LINK_INTO_LIBJVM must be defined
-# endif
-#endif
-
-/*
- * One job of the launcher is to remove command line options which the
- * vm does not understand and will not process. These options include
- * options which select which style of vm is run (e.g. -client and
- * -server) as well as options which select the data model to use.
- * Additionally, for tools which invoke an underlying vm "-J-foo"
- * options are turned into "-foo" options to the vm. This option
- * filtering is handled in a number of places in the launcher, some of
- * it in machine-dependent code. In this file, the function
- * CheckJVMType removes vm style options and TranslateApplicationArgs
- * removes "-J" prefixes. On unix platforms, the
- * CreateExecutionEnvironment function from the unix java_md.c file
- * processes and removes -d options. However, in case
- * CreateExecutionEnvironment does not need to exec because
- * LD_LIBRARY_PATH is set acceptably and the data model does not need
- * to be changed, ParseArguments will screen out the redundant -d
- * options and prevent them from being passed to the vm; this is done
- * by using the machine-dependent call
- * RemovableMachineDependentOption.
- */
-
-#include
-#include
-#include
-
-#include
-#include
-#include "java.h"
-#ifndef GAMMA
-#include "manifest_info.h"
-#include "version_comp.h"
-#include "splashscreen.h"
-#endif
-#include "wildcard.h"
-
-#ifndef FULL_VERSION
-#define FULL_VERSION JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
-#endif
-
-/*
- * The following environment variable is used to influence the behavior
- * of the jre exec'd through the SelectVersion routine. The command line
- * options which specify the version are not passed to the exec'd version,
- * because that jre may be an older version which wouldn't recognize them.
- * This environment variable is known to this (and later) version and serves
- * to suppress the version selection code. This is not only for efficiency,
- * but also for correctness, since any command line options have been
- * removed which would cause any value found in the manifest to be used.
- * This would be incorrect because the command line options are defined
- * to take precedence.
- *
- * The value associated with this environment variable is the MainClass
- * name from within the executable jar file (if any). This is strictly a
- * performance enhancement to avoid re-reading the jar file manifest.
- *
- * A NOTE TO DEVELOPERS: For performance reasons it is important that
- * the program image remain relatively small until after SelectVersion
- * CreateExecutionEnvironment have finished their possibly recursive
- * processing. Watch everything, but resist all temptations to use Java
- * interfaces.
- */
-#define ENV_ENTRY "_JAVA_VERSION_SET"
-
-#ifndef GAMMA
-#define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
-#define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
-#endif
-
-static jboolean printVersion = JNI_FALSE; /* print and exit */
-static jboolean showVersion = JNI_FALSE; /* print but continue */
-static char *progname;
-jboolean _launcher_debug = JNI_FALSE;
-
-#ifndef GAMMA
-/*
- * Entries for splash screen environment variables.
- * putenv is performed in SelectVersion. We need
- * them in memory until UnsetEnv, so they are made static
- * global instead of auto local.
- */
-static char* splash_file_entry = NULL;
-static char* splash_jar_entry = NULL;
-#endif
-
-/*
- * List of VM options to be specified when the VM is created.
- */
-static JavaVMOption *options;
-static int numOptions, maxOptions;
-
-/*
- * Prototypes for functions internal to launcher.
- */
-static void SetClassPath(const char *s);
-static void SelectVersion(int argc, char **argv, char **main_class);
-static jboolean ParseArguments(int *pargc, char ***pargv, char **pjarfile,
- char **pclassname, int *pret, const char *jvmpath);
-static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
- InvocationFunctions *ifn);
-static jstring NewPlatformString(JNIEnv *env, char *s);
-static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
-static jclass LoadClass(JNIEnv *env, char *name);
-static jstring GetMainClassName(JNIEnv *env, char *jarname);
-static void SetJavaCommandLineProp(char* classname, char* jarfile, int argc, char** argv);
-static void SetJavaLauncherProp(void);
-
-#ifdef JAVA_ARGS
-static void TranslateApplicationArgs(int *pargc, char ***pargv);
-static jboolean AddApplicationOptions(void);
-#endif
-
-static void PrintJavaVersion(JNIEnv *env);
-static void PrintUsage(void);
-static jint PrintXUsage(const char *jvmpath);
-
-static void SetPaths(int argc, char **argv);
-
-#ifndef GAMMA
-
-/* Maximum supported entries from jvm.cfg. */
-#define INIT_MAX_KNOWN_VMS 10
-/* Values for vmdesc.flag */
-#define VM_UNKNOWN -1
-#define VM_KNOWN 0
-#define VM_ALIASED_TO 1
-#define VM_WARN 2
-#define VM_ERROR 3
-#define VM_IF_SERVER_CLASS 4
-#define VM_IGNORE 5
-struct vmdesc {
- char *name;
- int flag;
- char *alias;
- char *server_class;
-};
-static struct vmdesc *knownVMs = NULL;
-static int knownVMsCount = 0;
-static int knownVMsLimit = 0;
-
-static void GrowKnownVMs();
-static int KnownVMIndex(const char* name);
-static void FreeKnownVMs();
-static void ShowSplashScreen();
-
-#endif /* ifndef GAMMA */
-
-jboolean ServerClassMachine();
-
-/* flag which if set suppresses error messages from the launcher */
-static int noExitErrorMessage = 0;
-
-/*
- * Running Java code in primordial thread caused many problems. We will
- * create a new thread to invoke JVM. See 6316197 for more information.
- */
-static jlong threadStackSize = 0; /* stack size of the new thread */
-
-int JNICALL JavaMain(void * args); /* entry point */
-
-struct JavaMainArgs {
- int argc;
- char ** argv;
- char * jarfile;
- char * classname;
- InvocationFunctions ifn;
-};
-
-/*
- * Entry point.
- */
-int
-main(int argc, char ** argv)
-{
- char *jarfile = 0;
- char *classname = 0;
- char *s = 0;
- char *main_class = NULL;
- int ret;
- InvocationFunctions ifn;
- jlong start, end;
- char jrepath[MAXPATHLEN], jvmpath[MAXPATHLEN];
- char ** original_argv = argv;
-
- if (getenv("_JAVA_LAUNCHER_DEBUG") != 0) {
- _launcher_debug = JNI_TRUE;
- printf("----_JAVA_LAUNCHER_DEBUG----\n");
- }
-
-#ifndef GAMMA
- /*
- * Make sure the specified version of the JRE is running.
- *
- * There are three things to note about the SelectVersion() routine:
- * 1) If the version running isn't correct, this routine doesn't
- * return (either the correct version has been exec'd or an error
- * was issued).
- * 2) Argc and Argv in this scope are *not* altered by this routine.
- * It is the responsibility of subsequent code to ignore the
- * arguments handled by this routine.
- * 3) As a side-effect, the variable "main_class" is guaranteed to
- * be set (if it should ever be set). This isn't exactly the
- * poster child for structured programming, but it is a small
- * price to pay for not processing a jar file operand twice.
- * (Note: This side effect has been disabled. See comment on
- * bugid 5030265 below.)
- */
- SelectVersion(argc, argv, &main_class);
-#endif /* ifndef GAMMA */
-
- /* copy original argv */
- {
- int i;
- original_argv = (char**)JLI_MemAlloc(sizeof(char*)*(argc+1));
- for(i = 0; i < argc+1; i++)
- original_argv[i] = argv[i];
- }
-
- CreateExecutionEnvironment(&argc, &argv,
- jrepath, sizeof(jrepath),
- jvmpath, sizeof(jvmpath),
- original_argv);
-
- printf("Using java runtime at: %s\n", jrepath);
-
- ifn.CreateJavaVM = 0;
- ifn.GetDefaultJavaVMInitArgs = 0;
-
- if (_launcher_debug)
- start = CounterGet();
- if (!LoadJavaVM(jvmpath, &ifn)) {
- exit(6);
- }
- if (_launcher_debug) {
- end = CounterGet();
- printf("%ld micro seconds to LoadJavaVM\n",
- (long)(jint)Counter2Micros(end-start));
- }
-
-#ifdef JAVA_ARGS /* javac, jar and friends. */
- progname = "java";
-#else /* java, oldjava, javaw and friends */
-#ifdef PROGNAME
- progname = PROGNAME;
-#else
- progname = *argv;
- if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
- progname = s + 1;
- }
-#endif /* PROGNAME */
-#endif /* JAVA_ARGS */
- ++argv;
- --argc;
-
-#ifdef JAVA_ARGS
- /* Preprocess wrapper arguments */
- TranslateApplicationArgs(&argc, &argv);
- if (!AddApplicationOptions()) {
- exit(1);
- }
-#endif
-
- /* Set default CLASSPATH */
- if ((s = getenv("CLASSPATH")) == 0) {
- s = ".";
- }
-#ifndef JAVA_ARGS
- SetClassPath(s);
-#endif
-
- /*
- * Parse command line options; if the return value of
- * ParseArguments is false, the program should exit.
- */
- if (!ParseArguments(&argc, &argv, &jarfile, &classname, &ret, jvmpath)) {
- exit(ret);
- }
-
- /* Override class path if -jar flag was specified */
- if (jarfile != 0) {
- SetClassPath(jarfile);
- }
-
- /* set the -Dsun.java.command pseudo property */
- SetJavaCommandLineProp(classname, jarfile, argc, argv);
-
- /* Set the -Dsun.java.launcher pseudo property */
- SetJavaLauncherProp();
-
- /* set the -Dsun.java.launcher.* platform properties */
- SetJavaLauncherPlatformProps();
-
-#ifndef GAMMA
- /* Show the splash screen if needed */
- ShowSplashScreen();
-#endif
-
- /*
- * Done with all command line processing and potential re-execs so
- * clean up the environment.
- */
- (void)UnsetEnv(ENV_ENTRY);
-#ifndef GAMMA
- (void)UnsetEnv(SPLASH_FILE_ENV_ENTRY);
- (void)UnsetEnv(SPLASH_JAR_ENV_ENTRY);
-
- JLI_MemFree(splash_jar_entry);
- JLI_MemFree(splash_file_entry);
-#endif
-
- /*
- * If user doesn't specify stack size, check if VM has a preference.
- * Note that HotSpot no longer supports JNI_VERSION_1_1 but it will
- * return its default stack size through the init args structure.
- */
- if (threadStackSize == 0) {
- struct JDK1_1InitArgs args1_1;
- memset((void*)&args1_1, 0, sizeof(args1_1));
- args1_1.version = JNI_VERSION_1_1;
- ifn.GetDefaultJavaVMInitArgs(&args1_1); /* ignore return value */
- if (args1_1.javaStackSize > 0) {
- threadStackSize = args1_1.javaStackSize;
- }
- }
-
- { /* Create a new thread to create JVM and invoke main method */
- struct JavaMainArgs args;
-
- args.argc = argc;
- args.argv = argv;
- args.jarfile = jarfile;
- args.classname = classname;
- args.ifn = ifn;
-
- return ContinueInNewThread(JavaMain, threadStackSize, (void*)&args);
- }
-}
-
-int JNICALL
-JavaMain(void * _args)
-{
- struct JavaMainArgs *args = (struct JavaMainArgs *)_args;
- int argc = args->argc;
- char **argv = args->argv;
- char *jarfile = args->jarfile;
- char *classname = args->classname;
- InvocationFunctions ifn = args->ifn;
-
- JavaVM *vm = 0;
- JNIEnv *env = 0;
- jstring mainClassName;
- jclass mainClass;
- jmethodID mainID;
- jobjectArray mainArgs;
- int ret = 0;
- jlong start, end;
-
- /*
- * Error message to print or display; by default the message will
- * only be displayed in a window.
- */
- char * message = "Fatal exception occurred. Program will exit.";
- jboolean messageDest = JNI_FALSE;
-
- /* Initialize the virtual machine */
-
- if (_launcher_debug)
- start = CounterGet();
- if (!InitializeJVM(&vm, &env, &ifn)) {
- ReportErrorMessage("Could not create the Java virtual machine.",
- JNI_TRUE);
- exit(1);
- }
-
- if (printVersion || showVersion) {
- PrintJavaVersion(env);
- if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- goto leave;
- }
- if (printVersion) {
- ret = 0;
- message = NULL;
- goto leave;
- }
- if (showVersion) {
- fprintf(stderr, "\n");
- }
- }
-
- /* If the user specified neither a class name nor a JAR file */
- if (jarfile == 0 && classname == 0) {
- PrintUsage();
- message = NULL;
- goto leave;
- }
-
-#ifndef GAMMA
- FreeKnownVMs(); /* after last possible PrintUsage() */
-#endif
-
- if (_launcher_debug) {
- end = CounterGet();
- printf("%ld micro seconds to InitializeJVM\n",
- (long)(jint)Counter2Micros(end-start));
- }
-
- /* At this stage, argc/argv have the applications' arguments */
- if (_launcher_debug) {
- int i = 0;
- printf("Main-Class is '%s'\n", classname ? classname : "");
- printf("Apps' argc is %d\n", argc);
- for (; i < argc; i++) {
- printf(" argv[%2d] = '%s'\n", i, argv[i]);
- }
- }
-
- ret = 1;
-
- /*
- * Get the application's main class.
- *
- * See bugid 5030265. The Main-Class name has already been parsed
- * from the manifest, but not parsed properly for UTF-8 support.
- * Hence the code here ignores the value previously extracted and
- * uses the pre-existing code to reextract the value. This is
- * possibly an end of release cycle expedient. However, it has
- * also been discovered that passing some character sets through
- * the environment has "strange" behavior on some variants of
- * Windows. Hence, maybe the manifest parsing code local to the
- * launcher should never be enhanced.
- *
- * Hence, future work should either:
- * 1) Correct the local parsing code and verify that the
- * Main-Class attribute gets properly passed through
- * all environments,
- * 2) Remove the vestages of maintaining main_class through
- * the environment (and remove these comments).
- */
- if (jarfile != 0) {
- mainClassName = GetMainClassName(env, jarfile);
- if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- goto leave;
- }
- if (mainClassName == NULL) {
- const char * format = "Failed to load Main-Class manifest "
- "attribute from\n%s";
- message = (char*)JLI_MemAlloc((strlen(format) + strlen(jarfile)) *
- sizeof(char));
- sprintf(message, format, jarfile);
- messageDest = JNI_TRUE;
- goto leave;
- }
- classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
- if (classname == NULL) {
- ReportExceptionDescription(env);
- goto leave;
- }
- mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
- const char * format = "Could not find the main class: %s. Program will exit.";
- ReportExceptionDescription(env);
- message = (char *)JLI_MemAlloc((strlen(format) +
- strlen(classname)) * sizeof(char) );
- messageDest = JNI_TRUE;
- sprintf(message, format, classname);
- goto leave;
- }
- (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
- } else {
- mainClassName = NewPlatformString(env, classname);
- if (mainClassName == NULL) {
- const char * format = "Failed to load Main Class: %s";
- message = (char *)JLI_MemAlloc((strlen(format) + strlen(classname)) *
- sizeof(char) );
- sprintf(message, format, classname);
- messageDest = JNI_TRUE;
- goto leave;
- }
- classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
- if (classname == NULL) {
- ReportExceptionDescription(env);
- goto leave;
- }
- mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
- const char * format = "Could not find the main class: %s. Program will exit.";
- ReportExceptionDescription(env);
- message = (char *)JLI_MemAlloc((strlen(format) +
- strlen(classname)) * sizeof(char) );
- messageDest = JNI_TRUE;
- sprintf(message, format, classname);
- goto leave;
- }
- (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
- }
-
- /* Get the application's main method */
- mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
- "([Ljava/lang/String;)V");
- if (mainID == NULL) {
- if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- } else {
- message = "No main method found in specified class.";
- messageDest = JNI_TRUE;
- }
- goto leave;
- }
-
- { /* Make sure the main method is public */
- jint mods;
- jmethodID mid;
- jobject obj = (*env)->ToReflectedMethod(env, mainClass,
- mainID, JNI_TRUE);
-
- if( obj == NULL) { /* exception occurred */
- ReportExceptionDescription(env);
- goto leave;
- }
-
- mid =
- (*env)->GetMethodID(env,
- (*env)->GetObjectClass(env, obj),
- "getModifiers", "()I");
- if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- goto leave;
- }
-
- mods = (*env)->CallIntMethod(env, obj, mid);
- if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
- message = "Main method not public.";
- messageDest = JNI_TRUE;
- goto leave;
- }
- }
-
- /* Build argument array */
- mainArgs = NewPlatformStringArray(env, argv, argc);
- if (mainArgs == NULL) {
- ReportExceptionDescription(env);
- goto leave;
- }
-
- /* Invoke main method. */
- (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
-
- /*
- * The launcher's exit code (in the absence of calls to
- * System.exit) will be non-zero if main threw an exception.
- */
- ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
-
- /*
- * Detach the main thread so that it appears to have ended when
- * the application's main method exits. This will invoke the
- * uncaught exception handler machinery if main threw an
- * exception. An uncaught exception handler cannot change the
- * launcher's return code except by calling System.exit.
- */
- if ((*vm)->DetachCurrentThread(vm) != 0) {
- message = "Could not detach main thread.";
- messageDest = JNI_TRUE;
- ret = 1;
- goto leave;
- }
-
- message = NULL;
-
- leave:
- /*
- * Wait for all non-daemon threads to end, then destroy the VM.
- * This will actually create a trivial new Java waiter thread
- * named "DestroyJavaVM", but this will be seen as a different
- * thread from the one that executed main, even though they are
- * the same C thread. This allows mainThread.join() and
- * mainThread.isAlive() to work as expected.
- */
- (*vm)->DestroyJavaVM(vm);
-
- if(message != NULL && !noExitErrorMessage)
- ReportErrorMessage(message, messageDest);
- return ret;
-}
-
-#ifndef GAMMA
-/*
- * Checks the command line options to find which JVM type was
- * specified. If no command line option was given for the JVM type,
- * the default type is used. The environment variable
- * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
- * checked as ways of specifying which JVM type to invoke.
- */
-char *
-CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
- int i, argi;
- int argc;
- char **newArgv;
- int newArgvIdx = 0;
- int isVMType;
- int jvmidx = -1;
- char *jvmtype = getenv("JDK_ALTERNATE_VM");
-
- argc = *pargc;
-
- /* To make things simpler we always copy the argv array */
- newArgv = JLI_MemAlloc((argc + 1) * sizeof(char *));
-
- /* The program name is always present */
- newArgv[newArgvIdx++] = (*argv)[0];
-
- for (argi = 1; argi < argc; argi++) {
- char *arg = (*argv)[argi];
- isVMType = 0;
-
-#ifdef JAVA_ARGS
- if (arg[0] != '-') {
- newArgv[newArgvIdx++] = arg;
- continue;
- }
-#else
- if (strcmp(arg, "-classpath") == 0 ||
- strcmp(arg, "-cp") == 0) {
- newArgv[newArgvIdx++] = arg;
- argi++;
- if (argi < argc) {
- newArgv[newArgvIdx++] = (*argv)[argi];
- }
- continue;
- }
- if (arg[0] != '-') break;
-#endif
-
- /* Did the user pass an explicit VM type? */
- i = KnownVMIndex(arg);
- if (i >= 0) {
- jvmtype = knownVMs[jvmidx = i].name + 1; /* skip the - */
- isVMType = 1;
- *pargc = *pargc - 1;
- }
-
- /* Did the user specify an "alternate" VM? */
- else if (strncmp(arg, "-XXaltjvm=", 10) == 0 || strncmp(arg, "-J-XXaltjvm=", 12) == 0) {
- isVMType = 1;
- jvmtype = arg+((arg[1]=='X')? 10 : 12);
- jvmidx = -1;
- }
-
- if (!isVMType) {
- newArgv[newArgvIdx++] = arg;
- }
- }
-
- /*
- * Finish copying the arguments if we aborted the above loop.
- * NOTE that if we aborted via "break" then we did NOT copy the
- * last argument above, and in addition argi will be less than
- * argc.
- */
- while (argi < argc) {
- newArgv[newArgvIdx++] = (*argv)[argi];
- argi++;
- }
-
- /* argv is null-terminated */
- newArgv[newArgvIdx] = 0;
-
- /* Copy back argv */
- *argv = newArgv;
- *pargc = newArgvIdx;
-
- /* use the default VM type if not specified (no alias processing) */
- if (jvmtype == NULL) {
- char* result = knownVMs[0].name+1;
- /* Use a different VM type if we are on a server class machine? */
- if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) &&
- (ServerClassMachine() == JNI_TRUE)) {
- result = knownVMs[0].server_class+1;
- }
- if (_launcher_debug) {
- printf("Default VM: %s\n", result);
- }
- return result;
- }
-
- /* if using an alternate VM, no alias processing */
- if (jvmidx < 0)
- return jvmtype;
-
- /* Resolve aliases first */
- {
- int loopCount = 0;
- while (knownVMs[jvmidx].flag == VM_ALIASED_TO) {
- int nextIdx = KnownVMIndex(knownVMs[jvmidx].alias);
-
- if (loopCount > knownVMsCount) {
- if (!speculative) {
- ReportErrorMessage("Error: Corrupt jvm.cfg file; cycle in alias list.",
- JNI_TRUE);
- exit(1);
- } else {
- return "ERROR";
- /* break; */
- }
- }
-
- if (nextIdx < 0) {
- if (!speculative) {
- ReportErrorMessage2("Error: Unable to resolve VM alias %s",
- knownVMs[jvmidx].alias, JNI_TRUE);
- exit(1);
- } else {
- return "ERROR";
- }
- }
- jvmidx = nextIdx;
- jvmtype = knownVMs[jvmidx].name+1;
- loopCount++;
- }
- }
-
- switch (knownVMs[jvmidx].flag) {
- case VM_WARN:
- if (!speculative) {
- fprintf(stderr, "Warning: %s VM not supported; %s VM will be used\n",
- jvmtype, knownVMs[0].name + 1);
- }
- /* fall through */
- case VM_IGNORE:
- jvmtype = knownVMs[jvmidx=0].name + 1;
- /* fall through */
- case VM_KNOWN:
- break;
- case VM_ERROR:
- if (!speculative) {
- ReportErrorMessage2("Error: %s VM not supported", jvmtype, JNI_TRUE);
- exit(1);
- } else {
- return "ERROR";
- }
- }
-
- return jvmtype;
-}
-#endif /* ifndef GAMMA */
-
-# define KB (1024UL)
-# define MB (1024UL * KB)
-# define GB (1024UL * MB)
-
-/* copied from HotSpot function "atomll()" */
-static int
-parse_stack_size(const char *s, jlong *result) {
- jlong n = 0;
- int args_read = sscanf(s, JLONG_FORMAT, &n);
- if (args_read != 1) {
- return 0;
- }
- while (*s != '\0' && *s >= '0' && *s <= '9') {
- s++;
- }
- // 4705540: illegal if more characters are found after the first non-digit
- if (strlen(s) > 1) {
- return 0;
- }
- switch (*s) {
- case 'T': case 't':
- *result = n * GB * KB;
- return 1;
- case 'G': case 'g':
- *result = n * GB;
- return 1;
- case 'M': case 'm':
- *result = n * MB;
- return 1;
- case 'K': case 'k':
- *result = n * KB;
- return 1;
- case '\0':
- *result = n;
- return 1;
- default:
- /* Create JVM with default stack and let VM handle malformed -Xss string*/
- return 0;
- }
-}
-
-/*
- * Adds a new VM option with the given given name and value.
- */
-void
-AddOption(char *str, void *info)
-{
- /*
- * Expand options array if needed to accommodate at least one more
- * VM option.
- */
- if (numOptions >= maxOptions) {
- if (options == 0) {
- maxOptions = 4;
- options = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
- } else {
- JavaVMOption *tmp;
- maxOptions *= 2;
- tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
- memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
- JLI_MemFree(options);
- options = tmp;
- }
- }
- options[numOptions].optionString = str;
- options[numOptions++].extraInfo = info;
-
- if (strncmp(str, "-Xss", 4) == 0) {
- jlong tmp;
- if (parse_stack_size(str + 4, &tmp)) {
- threadStackSize = tmp;
- }
- }
-}
-
-static void
-SetClassPath(const char *s)
-{
- char *def;
- s = JLI_WildcardExpandClasspath(s);
- def = JLI_MemAlloc(strlen(s) + 40);
- sprintf(def, "-Djava.class.path=%s", s);
- AddOption(def, NULL);
-}
-
-#ifndef GAMMA
-/*
- * The SelectVersion() routine ensures that an appropriate version of
- * the JRE is running. The specification for the appropriate version
- * is obtained from either the manifest of a jar file (preferred) or
- * from command line options.
- * The routine also parses splash screen command line options and
- * passes on their values in private environment variables.
- */
-static void
-SelectVersion(int argc, char **argv, char **main_class)
-{
- char *arg;
- char **new_argv;
- char **new_argp;
- char *operand;
- char *version = NULL;
- char *jre = NULL;
- int jarflag = 0;
- int headlessflag = 0;
- int restrict_search = -1; /* -1 implies not known */
- manifest_info info;
- char env_entry[MAXNAMELEN + 24] = ENV_ENTRY "=";
- char *splash_file_name = NULL;
- char *splash_jar_name = NULL;
- char *env_in;
- int res;
-
- /*
- * If the version has already been selected, set *main_class
- * with the value passed through the environment (if any) and
- * simply return.
- */
- if ((env_in = getenv(ENV_ENTRY)) != NULL) {
- if (*env_in != '\0')
- *main_class = JLI_StringDup(env_in);
- return;
- }
-
- /*
- * Scan through the arguments for options relevant to multiple JRE
- * support. For reference, the command line syntax is defined as:
- *
- * SYNOPSIS
- * java [options] class [argument...]
- *
- * java [options] -jar file.jar [argument...]
- *
- * As the scan is performed, make a copy of the argument list with
- * the version specification options (new to 1.5) removed, so that
- * a version less than 1.5 can be exec'd.
- *
- * Note that due to the syntax of the native Windows interface
- * CreateProcess(), processing similar to the following exists in
- * the Windows platform specific routine ExecJRE (in java_md.c).
- * Changes here should be reproduced there.
- */
- new_argv = JLI_MemAlloc((argc + 1) * sizeof(char*));
- new_argv[0] = argv[0];
- new_argp = &new_argv[1];
- argc--;
- argv++;
- while ((arg = *argv) != 0 && *arg == '-') {
- if (strncmp(arg, "-version:", 9) == 0) {
- version = arg + 9;
- } else if (strcmp(arg, "-jre-restrict-search") == 0) {
- restrict_search = 1;
- } else if (strcmp(arg, "-no-jre-restrict-search") == 0) {
- restrict_search = 0;
- } else {
- if (strcmp(arg, "-jar") == 0)
- jarflag = 1;
- /* deal with "unfortunate" classpath syntax */
- if ((strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) &&
- (argc >= 2)) {
- *new_argp++ = arg;
- argc--;
- argv++;
- arg = *argv;
- }
-
- /*
- * Checking for headless toolkit option in the some way as AWT does:
- * "true" means true and any other value means false
- */
- if (strcmp(arg, "-Djava.awt.headless=true") == 0) {
- headlessflag = 1;
- } else if (strncmp(arg, "-Djava.awt.headless=", 20) == 0) {
- headlessflag = 0;
- } else if (strncmp(arg, "-splash:", 8) == 0) {
- splash_file_name = arg+8;
- }
- *new_argp++ = arg;
- }
- argc--;
- argv++;
- }
- if (argc <= 0) { /* No operand? Possibly legit with -[full]version */
- operand = NULL;
- } else {
- argc--;
- *new_argp++ = operand = *argv++;
- }
- while (argc-- > 0) /* Copy over [argument...] */
- *new_argp++ = *argv++;
- *new_argp = NULL;
-
- /*
- * If there is a jar file, read the manifest. If the jarfile can't be
- * read, the manifest can't be read from the jar file, or the manifest
- * is corrupt, issue the appropriate error messages and exit.
- *
- * Even if there isn't a jar file, construct a manifest_info structure
- * containing the command line information. It's a convenient way to carry
- * this data around.
- */
- if (jarflag && operand) {
- if ((res = JLI_ParseManifest(operand, &info)) != 0) {
- if (res == -1)
- ReportErrorMessage2("Unable to access jarfile %s",
- operand, JNI_TRUE);
- else
- ReportErrorMessage2("Invalid or corrupt jarfile %s",
- operand, JNI_TRUE);
- exit(1);
- }
-
- /*
- * Command line splash screen option should have precedence
- * over the manifest, so the manifest data is used only if
- * splash_file_name has not been initialized above during command
- * line parsing
- */
- if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) {
- splash_file_name = info.splashscreen_image_file_name;
- splash_jar_name = operand;
- }
- } else {
- info.manifest_version = NULL;
- info.main_class = NULL;
- info.jre_version = NULL;
- info.jre_restrict_search = 0;
- }
-
- /*
- * Passing on splash screen info in environment variables
- */
- if (splash_file_name && !headlessflag) {
- char* splash_file_entry = JLI_MemAlloc(strlen(SPLASH_FILE_ENV_ENTRY "=")+strlen(splash_file_name)+1);
- strcpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "=");
- strcat(splash_file_entry, splash_file_name);
- putenv(splash_file_entry);
- }
- if (splash_jar_name && !headlessflag) {
- char* splash_jar_entry = JLI_MemAlloc(strlen(SPLASH_JAR_ENV_ENTRY "=")+strlen(splash_jar_name)+1);
- strcpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "=");
- strcat(splash_jar_entry, splash_jar_name);
- putenv(splash_jar_entry);
- }
-
- /*
- * The JRE-Version and JRE-Restrict-Search values (if any) from the
- * manifest are overwritten by any specified on the command line.
- */
- if (version != NULL)
- info.jre_version = version;
- if (restrict_search != -1)
- info.jre_restrict_search = restrict_search;
-
- /*
- * "Valid" returns (other than unrecoverable errors) follow. Set
- * main_class as a side-effect of this routine.
- */
- if (info.main_class != NULL)
- *main_class = JLI_StringDup(info.main_class);
-
- /*
- * If no version selection information is found either on the command
- * line or in the manifest, simply return.
- */
- if (info.jre_version == NULL) {
- JLI_FreeManifest();
- JLI_MemFree(new_argv);
- return;
- }
-
- /*
- * Check for correct syntax of the version specification (JSR 56).
- */
- if (!JLI_ValidVersionString(info.jre_version)) {
- ReportErrorMessage2("Syntax error in version specification \"%s\"",
- info.jre_version, JNI_TRUE);
- exit(1);
- }
-
- /*
- * Find the appropriate JVM on the system. Just to be as forgiving as
- * possible, if the standard algorithms don't locate an appropriate
- * jre, check to see if the one running will satisfy the requirements.
- * This can happen on systems which haven't been set-up for multiple
- * JRE support.
- */
- jre = LocateJRE(&info);
- if (_launcher_debug)
- printf("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n",
- (info.jre_version?info.jre_version:"null"),
- (info.jre_restrict_search?"true":"false"), (jre?jre:"null"));
- if (jre == NULL) {
- if (JLI_AcceptableRelease(FULL_VERSION, info.jre_version)) {
- JLI_FreeManifest();
- JLI_MemFree(new_argv);
- return;
- } else {
- ReportErrorMessage2(
- "Unable to locate JRE meeting specification \"%s\"",
- info.jre_version, JNI_TRUE);
- exit(1);
- }
- }
-
- /*
- * If I'm not the chosen one, exec the chosen one. Returning from
- * ExecJRE indicates that I am indeed the chosen one.
- *
- * The private environment variable _JAVA_VERSION_SET is used to
- * prevent the chosen one from re-reading the manifest file and
- * using the values found within to override the (potential) command
- * line flags stripped from argv (because the target may not
- * understand them). Passing the MainClass value is an optimization
- * to avoid locating, expanding and parsing the manifest extra
- * times.
- */
- if (info.main_class != NULL) {
- if (strlen(info.main_class) <= MAXNAMELEN) {
- (void)strcat(env_entry, info.main_class);
- } else {
- ReportErrorMessage("Error: main-class: attribute exceeds system limits\n", JNI_TRUE);
- exit(1);
- }
- }
- (void)putenv(env_entry);
- ExecJRE(jre, new_argv);
- JLI_FreeManifest();
- JLI_MemFree(new_argv);
- return;
-}
-#endif /* ifndef GAMMA */
-
-/*
- * Parses command line arguments. Returns JNI_FALSE if launcher
- * should exit without starting vm (e.g. certain version and usage
- * options); returns JNI_TRUE if vm needs to be started to process
- * given options. *pret (the launcher process return value) is set to
- * 0 for a normal exit.
- */
-static jboolean
-ParseArguments(int *pargc, char ***pargv, char **pjarfile,
- char **pclassname, int *pret, const char *jvmpath)
-{
- int argc = *pargc;
- char **argv = *pargv;
- jboolean jarflag = JNI_FALSE;
- char *arg;
-
- *pret = 1;
- while ((arg = *argv) != 0 && *arg == '-') {
- argv++; --argc;
- if (strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) {
- if (argc < 1) {
- ReportErrorMessage2("%s requires class path specification",
- arg, JNI_TRUE);
- PrintUsage();
- return JNI_FALSE;
- }
- SetClassPath(*argv);
- argv++; --argc;
- } else if (strcmp(arg, "-jar") == 0) {
- jarflag = JNI_TRUE;
- } else if (strcmp(arg, "-help") == 0 ||
- strcmp(arg, "-h") == 0 ||
- strcmp(arg, "-?") == 0) {
- PrintUsage();
- *pret = 0;
- return JNI_FALSE;
- } else if (strcmp(arg, "-version") == 0) {
- printVersion = JNI_TRUE;
- return JNI_TRUE;
- } else if (strcmp(arg, "-showversion") == 0) {
- showVersion = JNI_TRUE;
- } else if (strcmp(arg, "-X") == 0) {
- *pret = PrintXUsage(jvmpath);
- return JNI_FALSE;
-/*
- * The following case provide backward compatibility with old-style
- * command line options.
- */
- } else if (strcmp(arg, "-fullversion") == 0) {
- fprintf(stderr, "%s full version \"%s\"\n", progname,
- FULL_VERSION);
- *pret = 0;
- return JNI_FALSE;
- } else if (strcmp(arg, "-verbosegc") == 0) {
- AddOption("-verbose:gc", NULL);
- } else if (strcmp(arg, "-t") == 0) {
- AddOption("-Xt", NULL);
- } else if (strcmp(arg, "-tm") == 0) {
- AddOption("-Xtm", NULL);
- } else if (strcmp(arg, "-debug") == 0) {
- AddOption("-Xdebug", NULL);
- } else if (strcmp(arg, "-noclassgc") == 0) {
- AddOption("-Xnoclassgc", NULL);
- } else if (strcmp(arg, "-Xfuture") == 0) {
- AddOption("-Xverify:all", NULL);
- } else if (strcmp(arg, "-verify") == 0) {
- AddOption("-Xverify:all", NULL);
- } else if (strcmp(arg, "-verifyremote") == 0) {
- AddOption("-Xverify:remote", NULL);
- } else if (strcmp(arg, "-noverify") == 0) {
- AddOption("-Xverify:none", NULL);
- } else if (strcmp(arg, "-XXsuppressExitMessage") == 0) {
- noExitErrorMessage = 1;
- } else if (strncmp(arg, "-prof", 5) == 0) {
- char *p = arg + 5;
- char *tmp = JLI_MemAlloc(strlen(arg) + 50);
- if (*p) {
- sprintf(tmp, "-Xrunhprof:cpu=old,file=%s", p + 1);
- } else {
- sprintf(tmp, "-Xrunhprof:cpu=old,file=java.prof");
- }
- AddOption(tmp, NULL);
- } else if (strncmp(arg, "-ss", 3) == 0 ||
- strncmp(arg, "-oss", 4) == 0 ||
- strncmp(arg, "-ms", 3) == 0 ||
- strncmp(arg, "-mx", 3) == 0) {
- char *tmp = JLI_MemAlloc(strlen(arg) + 6);
- sprintf(tmp, "-X%s", arg + 1); /* skip '-' */
- AddOption(tmp, NULL);
- } else if (strcmp(arg, "-checksource") == 0 ||
- strcmp(arg, "-cs") == 0 ||
- strcmp(arg, "-noasyncgc") == 0) {
- /* No longer supported */
- fprintf(stderr,
- "Warning: %s option is no longer supported.\n",
- arg);
- } else if (strncmp(arg, "-version:", 9) == 0 ||
- strcmp(arg, "-no-jre-restrict-search") == 0 ||
- strcmp(arg, "-jre-restrict-search") == 0 ||
- strncmp(arg, "-splash:", 8) == 0) {
- ; /* Ignore machine independent options already handled */
- } else if (RemovableMachineDependentOption(arg) ) {
- ; /* Do not pass option to vm. */
- }
- else {
- AddOption(arg, NULL);
- }
- }
-
- if (--argc >= 0) {
- if (jarflag) {
- *pjarfile = *argv++;
- *pclassname = 0;
- } else {
- *pjarfile = 0;
- *pclassname = *argv++;
- }
- *pargc = argc;
- *pargv = argv;
- }
-
- return JNI_TRUE;
-}
-
-/*
- * Initializes the Java Virtual Machine. Also frees options array when
- * finished.
- */
-static jboolean
-InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
-{
- JavaVMInitArgs args;
- jint r;
-
- memset(&args, 0, sizeof(args));
- args.version = JNI_VERSION_1_2;
- args.nOptions = numOptions;
- args.options = options;
- args.ignoreUnrecognized = JNI_FALSE;
-
- if (_launcher_debug) {
- int i = 0;
- printf("JavaVM args:\n ");
- printf("version 0x%08lx, ", (long)args.version);
- printf("ignoreUnrecognized is %s, ",
- args.ignoreUnrecognized ? "JNI_TRUE" : "JNI_FALSE");
- printf("nOptions is %ld\n", (long)args.nOptions);
- for (i = 0; i < numOptions; i++)
- printf(" option[%2d] = '%s'\n",
- i, args.options[i].optionString);
- }
-
- r = ifn->CreateJavaVM(pvm, (void **)penv, &args);
- JLI_MemFree(options);
- return r == JNI_OK;
-}
-
-
-#define NULL_CHECK0(e) if ((e) == 0) return 0
-#define NULL_CHECK(e) if ((e) == 0) return
-
-static jstring platformEncoding = NULL;
-static jstring getPlatformEncoding(JNIEnv *env) {
- if (platformEncoding == NULL) {
- jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding");
- if (propname) {
- jclass cls;
- jmethodID mid;
- NULL_CHECK0 (cls = (*env)->FindClass(env, "java/lang/System"));
- NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
- env, cls,
- "getProperty",
- "(Ljava/lang/String;)Ljava/lang/String;"));
- platformEncoding = (*env)->CallStaticObjectMethod (
- env, cls, mid, propname);
- }
- }
- return platformEncoding;
-}
-
-static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
- jclass cls;
- jmethodID mid;
- NULL_CHECK0 (cls = (*env)->FindClass(env, "java/nio/charset/Charset"));
- NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
- env, cls,
- "isSupported",
- "(Ljava/lang/String;)Z"));
- return (*env)->CallStaticBooleanMethod(env, cls, mid, enc);
-}
-
-/*
- * Returns a new Java string object for the specified platform string.
- */
-static jstring
-NewPlatformString(JNIEnv *env, char *s)
-{
- int len = (int)strlen(s);
- jclass cls;
- jmethodID mid;
- jbyteArray ary;
- jstring enc;
-
- if (s == NULL)
- return 0;
- enc = getPlatformEncoding(env);
-
- ary = (*env)->NewByteArray(env, len);
- if (ary != 0) {
- jstring str = 0;
- (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
- if (!(*env)->ExceptionOccurred(env)) {
- if (isEncodingSupported(env, enc) == JNI_TRUE) {
- NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
- NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "",
- "([BLjava/lang/String;)V"));
- str = (*env)->NewObject(env, cls, mid, ary, enc);
- } else {
- /*If the encoding specified in sun.jnu.encoding is not
- endorsed by "Charset.isSupported" we have to fall back
- to use String(byte[]) explicitly here without specifying
- the encoding name, in which the StringCoding class will
- pickup the iso-8859-1 as the fallback converter for us.
- */
- NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
- NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "",
- "([B)V"));
- str = (*env)->NewObject(env, cls, mid, ary);
- }
- (*env)->DeleteLocalRef(env, ary);
- return str;
- }
- }
- return 0;
-}
-
-/*
- * Returns a new array of Java string objects for the specified
- * array of platform strings.
- */
-static jobjectArray
-NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
-{
- jarray cls;
- jarray ary;
- int i;
-
- NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
- NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));
- for (i = 0; i < strc; i++) {
- jstring str = NewPlatformString(env, *strv++);
- NULL_CHECK0(str);
- (*env)->SetObjectArrayElement(env, ary, i, str);
- (*env)->DeleteLocalRef(env, str);
- }
- return ary;
-}
-
-/*
- * Loads a class, convert the '.' to '/'.
- */
-static jclass
-LoadClass(JNIEnv *env, char *name)
-{
- char *buf = JLI_MemAlloc(strlen(name) + 1);
- char *s = buf, *t = name, c;
- jclass cls;
- jlong start, end;
-
- if (_launcher_debug)
- start = CounterGet();
-
- do {
- c = *t++;
- *s++ = (c == '.') ? '/' : c;
- } while (c != '\0');
- cls = (*env)->FindClass(env, buf);
- JLI_MemFree(buf);
-
- if (_launcher_debug) {
- end = CounterGet();
- printf("%ld micro seconds to load main class\n",
- (long)(jint)Counter2Micros(end-start));
- printf("----_JAVA_LAUNCHER_DEBUG----\n");
- }
-
- return cls;
-}
-
-
-/*
- * Returns the main class name for the specified jar file.
- */
-static jstring
-GetMainClassName(JNIEnv *env, char *jarname)
-{
-#define MAIN_CLASS "Main-Class"
- jclass cls;
- jmethodID mid;
- jobject jar, man, attr;
- jstring str, result = 0;
-
- NULL_CHECK0(cls = (*env)->FindClass(env, "java/util/jar/JarFile"));
- NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "",
- "(Ljava/lang/String;)V"));
- NULL_CHECK0(str = NewPlatformString(env, jarname));
- NULL_CHECK0(jar = (*env)->NewObject(env, cls, mid, str));
- NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "getManifest",
- "()Ljava/util/jar/Manifest;"));
- man = (*env)->CallObjectMethod(env, jar, mid);
- if (man != 0) {
- NULL_CHECK0(mid = (*env)->GetMethodID(env,
- (*env)->GetObjectClass(env, man),
- "getMainAttributes",
- "()Ljava/util/jar/Attributes;"));
- attr = (*env)->CallObjectMethod(env, man, mid);
- if (attr != 0) {
- NULL_CHECK0(mid = (*env)->GetMethodID(env,
- (*env)->GetObjectClass(env, attr),
- "getValue",
- "(Ljava/lang/String;)Ljava/lang/String;"));
- NULL_CHECK0(str = NewPlatformString(env, MAIN_CLASS));
- result = (*env)->CallObjectMethod(env, attr, mid, str);
- }
- }
- return result;
-}
-
-#ifdef JAVA_ARGS
-static char *java_args[] = JAVA_ARGS;
-static char *app_classpath[] = APP_CLASSPATH;
-
-/*
- * For tools, convert command line args thus:
- * javac -cp foo:foo/"*" -J-ms32m ...
- * java -ms32m -cp JLI_WildcardExpandClasspath(foo:foo/"*") ...
- */
-static void
-TranslateApplicationArgs(int *pargc, char ***pargv)
-{
- const int NUM_ARGS = (sizeof(java_args) / sizeof(char *));
- int argc = *pargc;
- char **argv = *pargv;
- int nargc = argc + NUM_ARGS;
- char **nargv = JLI_MemAlloc((nargc + 1) * sizeof(char *));
- int i;
-
- *pargc = nargc;
- *pargv = nargv;
-
- /* Copy the VM arguments (i.e. prefixed with -J) */
- for (i = 0; i < NUM_ARGS; i++) {
- char *arg = java_args[i];
- if (arg[0] == '-' && arg[1] == 'J') {
- *nargv++ = arg + 2;
- }
- }
-
- for (i = 0; i < argc; i++) {
- char *arg = argv[i];
- if (arg[0] == '-' && arg[1] == 'J') {
- if (arg[2] == '\0') {
- ReportErrorMessage("Error: the -J option should not be "
- "followed by a space.", JNI_TRUE);
- exit(1);
- }
- *nargv++ = arg + 2;
- }
- }
-
- /* Copy the rest of the arguments */
- for (i = 0; i < NUM_ARGS; i++) {
- char *arg = java_args[i];
- if (arg[0] != '-' || arg[1] != 'J') {
- *nargv++ = arg;
- }
- }
- for (i = 0; i < argc; i++) {
- char *arg = argv[i];
- if (arg[0] == '-') {
- if (arg[1] == 'J')
- continue;
-#ifdef EXPAND_CLASSPATH_WILDCARDS
- if (arg[1] == 'c'
- && (strcmp(arg, "-cp") == 0 ||
- strcmp(arg, "-classpath") == 0)
- && i < argc - 1) {
- *nargv++ = arg;
- *nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]);
- i++;
- continue;
- }
-#endif
- }
- *nargv++ = arg;
- }
- *nargv = 0;
-}
-
-/*
- * For our tools, we try to add 3 VM options:
- * -Denv.class.path=
- * -Dapplication.home=
- * -Djava.class.path=
- * is the user's setting of CLASSPATH -- for instance the user
- * tells javac where to find binary classes through this environment
- * variable. Notice that users will be able to compile against our
- * tools classes (sun.tools.javac.Main) only if they explicitly add
- * tools.jar to CLASSPATH.
- * is the directory where the application is installed.
- * is the classpath to where our apps' classfiles are.
- */
-static jboolean
-AddApplicationOptions()
-{
- const int NUM_APP_CLASSPATH = (sizeof(app_classpath) / sizeof(char *));
- char *envcp, *appcp, *apphome;
- char home[MAXPATHLEN]; /* application home */
- char separator[] = { PATH_SEPARATOR, '\0' };
- int size, i;
- int strlenHome;
-
- {
- const char *s = getenv("CLASSPATH");
- if (s) {
- s = (char *) JLI_WildcardExpandClasspath(s);
- /* 40 for -Denv.class.path= */
- envcp = (char *)JLI_MemAlloc(strlen(s) + 40);
- sprintf(envcp, "-Denv.class.path=%s", s);
- AddOption(envcp, NULL);
- }
- }
-
- if (!GetApplicationHome(home, sizeof(home))) {
- ReportErrorMessage("Can't determine application home", JNI_TRUE);
- return JNI_FALSE;
- }
-
- /* 40 for '-Dapplication.home=' */
- apphome = (char *)JLI_MemAlloc(strlen(home) + 40);
- sprintf(apphome, "-Dapplication.home=%s", home);
- AddOption(apphome, NULL);
-
- /* How big is the application's classpath? */
- size = 40; /* 40: "-Djava.class.path=" */
- strlenHome = (int)strlen(home);
- for (i = 0; i < NUM_APP_CLASSPATH; i++) {
- size += strlenHome + (int)strlen(app_classpath[i]) + 1; /* 1: separator */
- }
- appcp = (char *)JLI_MemAlloc(size + 1);
- strcpy(appcp, "-Djava.class.path=");
- for (i = 0; i < NUM_APP_CLASSPATH; i++) {
- strcat(appcp, home); /* c:\program files\myapp */
- strcat(appcp, app_classpath[i]); /* \lib\myapp.jar */
- strcat(appcp, separator); /* ; */
- }
- appcp[strlen(appcp)-1] = '\0'; /* remove trailing path separator */
- AddOption(appcp, NULL);
- return JNI_TRUE;
-}
-#endif /* JAVA_ARGS */
-
-/*
- * inject the -Dsun.java.command pseudo property into the args structure
- * this pseudo property is used in the HotSpot VM to expose the
- * Java class name and arguments to the main method to the VM. The
- * HotSpot VM uses this pseudo property to store the Java class name
- * (or jar file name) and the arguments to the class's main method
- * to the instrumentation memory region. The sun.java.command pseudo
- * property is not exported by HotSpot to the Java layer.
- */
-void
-SetJavaCommandLineProp(char *classname, char *jarfile,
- int argc, char **argv)
-{
-
- int i = 0;
- size_t len = 0;
- char* javaCommand = NULL;
- char* dashDstr = "-Dsun.java.command=";
-
- if (classname == NULL && jarfile == NULL) {
- /* unexpected, one of these should be set. just return without
- * setting the property
- */
- return;
- }
-
- /* if the class name is not set, then use the jarfile name */
- if (classname == NULL) {
- classname = jarfile;
- }
-
- /* determine the amount of memory to allocate assuming
- * the individual components will be space separated
- */
- len = strlen(classname);
- for (i = 0; i < argc; i++) {
- len += strlen(argv[i]) + 1;
- }
-
- /* allocate the memory */
- javaCommand = (char*) JLI_MemAlloc(len + strlen(dashDstr) + 1);
-
- /* build the -D string */
- *javaCommand = '\0';
- strcat(javaCommand, dashDstr);
- strcat(javaCommand, classname);
-
- for (i = 0; i < argc; i++) {
- /* the components of the string are space separated. In
- * the case of embedded white space, the relationship of
- * the white space separated components to their true
- * positional arguments will be ambiguous. This issue may
- * be addressed in a future release.
- */
- strcat(javaCommand, " ");
- strcat(javaCommand, argv[i]);
- }
-
- AddOption(javaCommand, NULL);
-}
-
-/*
- * JVM would like to know if it's created by a standard Sun launcher, or by
- * user native application, the following property indicates the former.
- */
-void SetJavaLauncherProp() {
- AddOption("-Dsun.java.launcher=" LAUNCHER_TYPE, NULL);
-}
-
-/*
- * Prints the version information from the java.version and other properties.
- */
-static void
-PrintJavaVersion(JNIEnv *env)
-{
- jclass ver;
- jmethodID print;
-
- NULL_CHECK(ver = (*env)->FindClass(env, "sun/misc/Version"));
- NULL_CHECK(print = (*env)->GetStaticMethodID(env, ver, "print", "()V"));
-
- (*env)->CallStaticVoidMethod(env, ver, print);
-}
-
-/*
- * Prints default usage message.
- */
-static void
-PrintUsage(void)
-{
-#ifndef GAMMA
- int i;
-#endif
-
- fprintf(stdout,
- "Usage: %s [-options] class [args...]\n"
- " (to execute a class)\n"
- " or %s [-options] -jar jarfile [args...]\n"
- " (to execute a jar file)\n"
- "\n"
- "where options include:\n",
- progname,
- progname);
-
-#ifndef GAMMA
- PrintMachineDependentOptions();
-
- if ((knownVMs[0].flag == VM_KNOWN) ||
- (knownVMs[0].flag == VM_IF_SERVER_CLASS)) {
- fprintf(stdout, " %s\t to select the \"%s\" VM\n",
- knownVMs[0].name, knownVMs[0].name+1);
- }
- for (i=1; i\n"
-" -classpath \n"
-" A %c separated list of directories, JAR archives,\n"
-" and ZIP archives to search for class files.\n"
-" -D=\n"
-" set a system property\n"
-" -verbose[:class|gc|jni]\n"
-" enable verbose output\n"
-" -version print product version and exit\n"
-" -version:\n"
-" require the specified version to run\n"
-" -showversion print product version and continue\n"
-" -jre-restrict-search | -jre-no-restrict-search\n"
-" include/exclude user private JREs in the version search\n"
-" -? -help print this help message\n"
-" -X print help on non-standard options\n"
-" -ea[:...|:]\n"
-" -enableassertions[:...|:]\n"
-" enable assertions\n"
-" -da[:...|:]\n"
-" -disableassertions[:...|:]\n"
-" disable assertions\n"
-" -esa | -enablesystemassertions\n"
-" enable system assertions\n"
-" -dsa | -disablesystemassertions\n"
-" disable system assertions\n"
-" -agentlib:[=]\n"
-" load native agent library , e.g. -agentlib:hprof\n"
-" see also, -agentlib:jdwp=help and -agentlib:hprof=help\n"
-" -agentpath:[=]\n"
-" load native agent library by full pathname\n"
-" -javaagent:[=]\n"
-" load Java programming language agent, see java.lang.instrument\n"
-" -splash:\n"
-" show splash screen with specified image\n"
-
- ,PATH_SEPARATOR);
-}
-
-/*
- * Print usage message for -X options.
- */
-static jint
-PrintXUsage(const char *jvmpath)
-{
- /*
- A 32 bit cushion to prevent buffer overrun, noting that
- fopen(3C) may fail if the buffer exceeds MAXPATHLEN.
- */
- char path[MAXPATHLEN+32];
- char buf[128];
- size_t n;
- FILE *fp;
- static const char Xusage_txt[] = "/Xusage.txt";
-
- strcpy(path, jvmpath);
- /* Note the FILE_SEPARATOR is platform dependent */
- strcpy(strrchr(path, FILE_SEPARATOR), Xusage_txt);
- fp = fopen(path, "r");
- if (fp == 0) {
- fprintf(stderr, "Can't open %s\n", path);
- return 1;
- }
- while ((n = fread(buf, 1, sizeof(buf), fp)) != 0) {
- fwrite(buf, 1, n, stdout);
- }
- fclose(fp);
- return 0;
-}
-
-#ifndef GAMMA
-/*
- * Read the jvm.cfg file and fill the knownJVMs[] array.
- *
- * The functionality of the jvm.cfg file is subject to change without
- * notice and the mechanism will be removed in the future.
- *
- * The lexical structure of the jvm.cfg file is as follows:
- *
- * jvmcfg := { vmLine }
- * vmLine := knownLine
- * | aliasLine
- * | warnLine
- * | ignoreLine
- * | errorLine
- * | predicateLine
- * | commentLine
- * knownLine := flag "KNOWN" EOL
- * warnLine := flag "WARN" EOL
- * ignoreLine := flag "IGNORE" EOL
- * errorLine := flag "ERROR" EOL
- * aliasLine := flag "ALIASED_TO" flag EOL
- * predicateLine := flag "IF_SERVER_CLASS" flag EOL
- * commentLine := "#" text EOL
- * flag := "-" identifier
- *
- * The semantics are that when someone specifies a flag on the command line:
- * - if the flag appears on a knownLine, then the identifier is used as
- * the name of the directory holding the JVM library (the name of the JVM).
- * - if the flag appears as the first flag on an aliasLine, the identifier
- * of the second flag is used as the name of the JVM.
- * - if the flag appears on a warnLine, the identifier is used as the
- * name of the JVM, but a warning is generated.
- * - if the flag appears on an ignoreLine, the identifier is recognized as the
- * name of a JVM, but the identifier is ignored and the default vm used
- * - if the flag appears on an errorLine, an error is generated.
- * - if the flag appears as the first flag on a predicateLine, and
- * the machine on which you are running passes the predicate indicated,
- * then the identifier of the second flag is used as the name of the JVM,
- * otherwise the identifier of the first flag is used as the name of the JVM.
- * If no flag is given on the command line, the first vmLine of the jvm.cfg
- * file determines the name of the JVM.
- * PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
- * since they only make sense if someone hasn't specified the name of the
- * JVM on the command line.
- *
- * The intent of the jvm.cfg file is to allow several JVM libraries to
- * be installed in different subdirectories of a single JRE installation,
- * for space-savings and convenience in testing.
- * The intent is explicitly not to provide a full aliasing or predicate
- * mechanism.
- */
-jint
-ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative)
-{
- FILE *jvmCfg;
- char jvmCfgName[MAXPATHLEN+20];
- char line[MAXPATHLEN+20];
- int cnt = 0;
- int lineno = 0;
- jlong start, end;
- int vmType;
- char *tmpPtr;
- char *altVMName = NULL;
- char *serverClassVMName = NULL;
- static char *whiteSpace = " \t";
- if (_launcher_debug) {
- start = CounterGet();
- }
-
- strcpy(jvmCfgName, jrepath);
- strcat(jvmCfgName, FILESEP "lib" FILESEP);
- strcat(jvmCfgName, arch);
- strcat(jvmCfgName, FILESEP "jvm.cfg");
-
- jvmCfg = fopen(jvmCfgName, "r");
- if (jvmCfg == NULL) {
- if (!speculative) {
- ReportErrorMessage2("Error: could not open `%s'", jvmCfgName,
- JNI_TRUE);
- exit(1);
- } else {
- return -1;
- }
- }
- while (fgets(line, sizeof(line), jvmCfg) != NULL) {
- vmType = VM_UNKNOWN;
- lineno++;
- if (line[0] == '#')
- continue;
- if (line[0] != '-') {
- fprintf(stderr, "Warning: no leading - on line %d of `%s'\n",
- lineno, jvmCfgName);
- }
- if (cnt >= knownVMsLimit) {
- GrowKnownVMs(cnt);
- }
- line[strlen(line)-1] = '\0'; /* remove trailing newline */
- tmpPtr = line + strcspn(line, whiteSpace);
- if (*tmpPtr == 0) {
- fprintf(stderr, "Warning: missing VM type on line %d of `%s'\n",
- lineno, jvmCfgName);
- } else {
- /* Null-terminate this string for JLI_StringDup below */
- *tmpPtr++ = 0;
- tmpPtr += strspn(tmpPtr, whiteSpace);
- if (*tmpPtr == 0) {
- fprintf(stderr, "Warning: missing VM type on line %d of `%s'\n",
- lineno, jvmCfgName);
- } else {
- if (!strncmp(tmpPtr, "KNOWN", strlen("KNOWN"))) {
- vmType = VM_KNOWN;
- } else if (!strncmp(tmpPtr, "ALIASED_TO", strlen("ALIASED_TO"))) {
- tmpPtr += strcspn(tmpPtr, whiteSpace);
- if (*tmpPtr != 0) {
- tmpPtr += strspn(tmpPtr, whiteSpace);
- }
- if (*tmpPtr == 0) {
- fprintf(stderr, "Warning: missing VM alias on line %d of `%s'\n",
- lineno, jvmCfgName);
- } else {
- /* Null terminate altVMName */
- altVMName = tmpPtr;
- tmpPtr += strcspn(tmpPtr, whiteSpace);
- *tmpPtr = 0;
- vmType = VM_ALIASED_TO;
- }
- } else if (!strncmp(tmpPtr, "WARN", strlen("WARN"))) {
- vmType = VM_WARN;
- } else if (!strncmp(tmpPtr, "IGNORE", strlen("IGNORE"))) {
- vmType = VM_IGNORE;
- } else if (!strncmp(tmpPtr, "ERROR", strlen("ERROR"))) {
- vmType = VM_ERROR;
- } else if (!strncmp(tmpPtr,
- "IF_SERVER_CLASS",
- strlen("IF_SERVER_CLASS"))) {
- tmpPtr += strcspn(tmpPtr, whiteSpace);
- if (*tmpPtr != 0) {
- tmpPtr += strspn(tmpPtr, whiteSpace);
- }
- if (*tmpPtr == 0) {
- fprintf(stderr, "Warning: missing server class VM on line %d of `%s'\n",
- lineno, jvmCfgName);
- } else {
- /* Null terminate server class VM name */
- serverClassVMName = tmpPtr;
- tmpPtr += strcspn(tmpPtr, whiteSpace);
- *tmpPtr = 0;
- vmType = VM_IF_SERVER_CLASS;
- }
- } else {
- fprintf(stderr, "Warning: unknown VM type on line %d of `%s'\n",
- lineno, &jvmCfgName[0]);
- vmType = VM_KNOWN;
- }
- }
- }
-
- if (_launcher_debug)
- printf("jvm.cfg[%d] = ->%s<-\n", cnt, line);
- if (vmType != VM_UNKNOWN) {
- knownVMs[cnt].name = JLI_StringDup(line);
- knownVMs[cnt].flag = vmType;
- switch (vmType) {
- default:
- break;
- case VM_ALIASED_TO:
- knownVMs[cnt].alias = JLI_StringDup(altVMName);
- if (_launcher_debug) {
- printf(" name: %s vmType: %s alias: %s\n",
- knownVMs[cnt].name, "VM_ALIASED_TO", knownVMs[cnt].alias);
- }
- break;
- case VM_IF_SERVER_CLASS:
- knownVMs[cnt].server_class = JLI_StringDup(serverClassVMName);
- if (_launcher_debug) {
- printf(" name: %s vmType: %s server_class: %s\n",
- knownVMs[cnt].name, "VM_IF_SERVER_CLASS", knownVMs[cnt].server_class);
- }
- break;
- }
- cnt++;
- }
- }
- fclose(jvmCfg);
- knownVMsCount = cnt;
-
- if (_launcher_debug) {
- end = CounterGet();
- printf("%ld micro seconds to parse jvm.cfg\n",
- (long)(jint)Counter2Micros(end-start));
- }
-
- return cnt;
-}
-
-
-static void
-GrowKnownVMs(int minimum)
-{
- struct vmdesc* newKnownVMs;
- int newMax;
-
- newMax = (knownVMsLimit == 0 ? INIT_MAX_KNOWN_VMS : (2 * knownVMsLimit));
- if (newMax <= minimum) {
- newMax = minimum;
- }
- newKnownVMs = (struct vmdesc*) JLI_MemAlloc(newMax * sizeof(struct vmdesc));
- if (knownVMs != NULL) {
- memcpy(newKnownVMs, knownVMs, knownVMsLimit * sizeof(struct vmdesc));
- }
- JLI_MemFree(knownVMs);
- knownVMs = newKnownVMs;
- knownVMsLimit = newMax;
-}
-
-
-/* Returns index of VM or -1 if not found */
-static int
-KnownVMIndex(const char* name)
-{
- int i;
- if (strncmp(name, "-J", 2) == 0) name += 2;
- for (i = 0; i < knownVMsCount; i++) {
- if (!strcmp(name, knownVMs[i].name)) {
- return i;
- }
- }
- return -1;
-}
-
-static void
-FreeKnownVMs()
-{
- int i;
- for (i = 0; i < knownVMsCount; i++) {
- JLI_MemFree(knownVMs[i].name);
- knownVMs[i].name = NULL;
- }
- JLI_MemFree(knownVMs);
-}
-
-
-/*
- * Displays the splash screen according to the jar file name
- * and image file names stored in environment variables
- */
-static void
-ShowSplashScreen()
-{
- const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
- const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY);
- int data_size;
- void *image_data;
- if (jar_name) {
- image_data = JLI_JarUnpackFile(jar_name, file_name, &data_size);
- if (image_data) {
- DoSplashInit();
- DoSplashLoadMemory(image_data, data_size);
- JLI_MemFree(image_data);
- }
- } else if (file_name) {
- DoSplashInit();
- DoSplashLoadFile(file_name);
- } else {
- return;
- }
- DoSplashSetFileJarName(file_name, jar_name);
-}
-
-#endif /* ifndef GAMMA */
diff --git a/hotspot/src/share/tools/launcher/java.h b/hotspot/src/share/tools/launcher/java.h
deleted file mode 100644
index 1dd79618c84..00000000000
--- a/hotspot/src/share/tools/launcher/java.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1999, 2013, 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.
- *
- */
-
-
-#ifndef _JAVA_H_
-#define _JAVA_H_
-
-/*
- * Get system specific defines.
- */
-#include "jni.h"
-#include "java_md.h"
-#include "jli_util.h"
-
-/*
- * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
- */
-typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
-typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
-
-typedef struct {
- CreateJavaVM_t CreateJavaVM;
- GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
-} InvocationFunctions;
-
-/*
- * Prototypes for launcher functions in the system specific java_md.c.
- */
-
-jboolean
-LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
-
-void
-GetXUsagePath(char *buf, jint bufsize);
-
-jboolean
-GetApplicationHome(char *buf, jint bufsize);
-
-const char *
-GetArch();
-
-void CreateExecutionEnvironment(int *_argc,
- char ***_argv,
- char jrepath[],
- jint so_jrepath,
- char jvmpath[],
- jint so_jvmpath,
- char **original_argv);
-
-/*
- * Report an error message to stderr or a window as appropriate. The
- * flag always is set to JNI_TRUE if message is to be reported to both
- * strerr and windows and set to JNI_FALSE if the message should only
- * be sent to a window.
- */
-void ReportErrorMessage(char * message, jboolean always);
-void ReportErrorMessage2(char * format, char * string, jboolean always);
-
-/*
- * Report an exception which terminates the vm to stderr or a window
- * as appropriate.
- */
-void ReportExceptionDescription(JNIEnv * env);
-
-jboolean RemovableMachineDependentOption(char * option);
-void PrintMachineDependentOptions();
-
-/*
- * Block current thread and continue execution in new thread
- */
-int ContinueInNewThread(int (JNICALL *continuation)(void *),
- jlong stack_size, void * args);
-
-/* sun.java.launcher.* platform properties. */
-void SetJavaLauncherPlatformProps(void);
-
-/*
- * Functions defined in java.c and used in java_md.c.
- */
-jint ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative);
-char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
-void AddOption(char *str, void *info);
-
-/*
- * Make launcher spit debug output.
- */
-extern jboolean _launcher_debug;
-
-#endif /* _JAVA_H_ */
diff --git a/hotspot/src/share/tools/launcher/jli_util.c b/hotspot/src/share/tools/launcher/jli_util.c
deleted file mode 100644
index 36b164e3d37..00000000000
--- a/hotspot/src/share/tools/launcher/jli_util.c
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * Copyright (c) 1999, 2010, 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.
- *
- */
-
-#include
-#include
-#include "jli_util.h"
-
-#ifdef GAMMA
-#ifdef TARGET_OS_FAMILY_windows
-#define strdup _strdup
-#endif
-#endif
-
-/*
- * Returns a pointer to a block of at least 'size' bytes of memory.
- * Prints error message and exits if the memory could not be allocated.
- */
-void *
-JLI_MemAlloc(size_t size)
-{
- void *p = malloc(size);
- if (p == 0) {
- perror("malloc");
- exit(1);
- }
- return p;
-}
-
-/*
- * Equivalent to realloc(size).
- * Prints error message and exits if the memory could not be reallocated.
- */
-void *
-JLI_MemRealloc(void *ptr, size_t size)
-{
- void *p = realloc(ptr, size);
- if (p == 0) {
- perror("realloc");
- exit(1);
- }
- return p;
-}
-
-/*
- * Wrapper over strdup(3C) which prints an error message and exits if memory
- * could not be allocated.
- */
-char *
-JLI_StringDup(const char *s1)
-{
- char *s = strdup(s1);
- if (s == NULL) {
- perror("strdup");
- exit(1);
- }
- return s;
-}
-
-/*
- * Very equivalent to free(ptr).
- * Here to maintain pairing with the above routines.
- */
-void
-JLI_MemFree(void *ptr)
-{
- free(ptr);
-}
diff --git a/hotspot/src/share/tools/launcher/jli_util.h b/hotspot/src/share/tools/launcher/jli_util.h
deleted file mode 100644
index 535f7c482c1..00000000000
--- a/hotspot/src/share/tools/launcher/jli_util.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 1999, 2010, 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.
- *
- */
-
-#ifndef _JLI_UTIL_H
-#define _JLI_UTIL_H
-
-#include
-
-void *JLI_MemAlloc(size_t size);
-void *JLI_MemRealloc(void *ptr, size_t size);
-char *JLI_StringDup(const char *s1);
-void JLI_MemFree(void *ptr);
-
-#endif /* _JLI_UTIL_H */
diff --git a/hotspot/src/share/tools/launcher/wildcard.c b/hotspot/src/share/tools/launcher/wildcard.c
deleted file mode 100644
index 8b3cbcd69c4..00000000000
--- a/hotspot/src/share/tools/launcher/wildcard.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Copyright (c) 1999, 2010, 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.
- *
- */
-
-/*
- * Class-Path Wildcards
- *
- * The syntax for wildcards is a single asterisk. The class path
- * foo/"*", e.g., loads all jar files in the directory named foo.
- * (This requires careful quotation when used in shell scripts.)
- *
- * Only files whose names end in .jar or .JAR are matched.
- * Files whose names end in .zip, or which have a particular
- * magic number, regardless of filename extension, are not
- * matched.
- *
- * Files are considered regardless of whether or not they are
- * "hidden" in the UNIX sense, i.e., have names beginning with '.'.
- *
- * A wildcard only matches jar files, not class files in the same
- * directory. If you want to load both class files and jar files from
- * a single directory foo then you can say foo:foo/"*", or foo/"*":foo
- * if you want the jar files to take precedence.
- *
- * Subdirectories are not searched recursively, i.e., foo/"*" only
- * looks for jar files in foo, not in foo/bar, foo/baz, etc.
- *
- * Expansion of wildcards is done early, prior to the invocation of a
- * program's main method, rather than late, during the class-loading
- * process itself. Each element of the input class path containing a
- * wildcard is replaced by the (possibly empty) sequence of elements
- * generated by enumerating the jar files in the named directory. If
- * the directory foo contains a.jar, b.jar, and c.jar,
- * e.g., then the class path foo/"*" is expanded into
- * foo/a.jar:foo/b.jar:foo/c.jar, and that string would be the value
- * of the system property java.class.path.
- *
- * The order in which the jar files in a directory are enumerated in
- * the expanded class path is not specified and may vary from platform
- * to platform and even from moment to moment on the same machine. A
- * well-constructed application should not depend upon any particular
- * order. If a specific order is required then the jar files can be
- * enumerated explicitly in the class path.
- *
- * The CLASSPATH environment variable is not treated any differently
- * from the -classpath (equiv. -cp) command-line option,
- * i.e. wildcards are honored in all these cases.
- *
- * Class-path wildcards are not honored in the Class-Path jar-manifest
- * header.
- *
- * Class-path wildcards are honored not only by the Java launcher but
- * also by most other command-line tools that accept class paths, and
- * in particular by javac and javadoc.
- *
- * Class-path wildcards are not honored in any other kind of path, and
- * especially not in the bootstrap class path, which is a mere
- * artifact of our implementation and not something that developers
- * should use.
- *
- * Classpath wildcards are only expanded in the Java launcher code,
- * supporting the use of wildcards on the command line and in the
- * CLASSPATH environment variable. We do not support the use of
- * wildcards by applications that embed the JVM.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include "java.h" /* Strictly for PATH_SEPARATOR/FILE_SEPARATOR */
-#include "jli_util.h"
-
-#ifdef _WIN32
-#include
-#else /* Unix */
-#include
-#include
-#endif /* Unix */
-
-static int
-exists(const char* filename)
-{
-#ifdef _WIN32
- return _access(filename, 0) == 0;
-#else
- return access(filename, F_OK) == 0;
-#endif
-}
-
-#define NEW_(TYPE) ((TYPE) JLI_MemAlloc(sizeof(struct TYPE##_)))
-
-/*
- * Wildcard directory iteration.
- * WildcardIterator_for(wildcard) returns an iterator.
- * Each call to that iterator's next() method returns the basename
- * of an entry in the wildcard's directory. The basename's memory
- * belongs to the iterator. The caller is responsible for prepending
- * the directory name and file separator, if necessary.
- * When done with the iterator, call the close method to clean up.
- */
-typedef struct WildcardIterator_* WildcardIterator;
-
-#ifdef _WIN32
-struct WildcardIterator_
-{
- HANDLE handle;
- char *firstFile; /* Stupid FindFirstFile...FindNextFile */
-};
-
-static WildcardIterator
-WildcardIterator_for(const char *wildcard)
-{
- WIN32_FIND_DATA find_data;
- WildcardIterator it = NEW_(WildcardIterator);
- HANDLE handle = FindFirstFile(wildcard, &find_data);
- if (handle == INVALID_HANDLE_VALUE)
- return NULL;
- it->handle = handle;
- it->firstFile = find_data.cFileName;
- return it;
-}
-
-static char *
-WildcardIterator_next(WildcardIterator it)
-{
- WIN32_FIND_DATA find_data;
- if (it->firstFile != NULL) {
- char *firstFile = it->firstFile;
- it->firstFile = NULL;
- return firstFile;
- }
- return FindNextFile(it->handle, &find_data)
- ? find_data.cFileName : NULL;
-}
-
-static void
-WildcardIterator_close(WildcardIterator it)
-{
- if (it) {
- FindClose(it->handle);
- JLI_MemFree(it->firstFile);
- JLI_MemFree(it);
- }
-}
-
-#else /* Unix */
-struct WildcardIterator_
-{
- DIR *dir;
-};
-
-static WildcardIterator
-WildcardIterator_for(const char *wildcard)
-{
- DIR *dir;
- int wildlen = strlen(wildcard);
- if (wildlen < 2) {
- dir = opendir(".");
- } else {
- char *dirname = JLI_StringDup(wildcard);
- dirname[wildlen - 1] = '\0';
- dir = opendir(dirname);
- JLI_MemFree(dirname);
- }
- if (dir == NULL)
- return NULL;
- else {
- WildcardIterator it = NEW_(WildcardIterator);
- it->dir = dir;
- return it;
- }
-}
-
-static char *
-WildcardIterator_next(WildcardIterator it)
-{
- struct dirent* dirp = readdir(it->dir);
- return dirp ? dirp->d_name : NULL;
-}
-
-static void
-WildcardIterator_close(WildcardIterator it)
-{
- if (it) {
- closedir(it->dir);
- JLI_MemFree(it);
- }
-}
-#endif /* Unix */
-
-static int
-equal(const char *s1, const char *s2)
-{
- return strcmp(s1, s2) == 0;
-}
-
-/*
- * FileList ADT - a dynamic list of C filenames
- */
-struct FileList_
-{
- char **files;
- int size;
- int capacity;
-};
-typedef struct FileList_ *FileList;
-
-static FileList
-FileList_new(int capacity)
-{
- FileList fl = NEW_(FileList);
- fl->capacity = capacity;
- fl->files = (char **) JLI_MemAlloc(capacity * sizeof(fl->files[0]));
- fl->size = 0;
- return fl;
-}
-
-#ifdef DEBUG_WILDCARD
-static void
-FileList_print(FileList fl)
-{
- int i;
- putchar('[');
- for (i = 0; i < fl->size; i++) {
- if (i > 0) printf(", ");
- printf("\"%s\"",fl->files[i]);
- }
- putchar(']');
-}
-#endif
-
-static void
-FileList_free(FileList fl)
-{
- if (fl) {
- if (fl->files) {
- int i;
- for (i = 0; i < fl->size; i++)
- JLI_MemFree(fl->files[i]);
- JLI_MemFree(fl->files);
- }
- JLI_MemFree(fl);
- }
-}
-
-static void
-FileList_ensureCapacity(FileList fl, int capacity)
-{
- if (fl->capacity < capacity) {
- while (fl->capacity < capacity)
- fl->capacity *= 2;
- fl->files = JLI_MemRealloc(fl->files,
- fl->capacity * sizeof(fl->files[0]));
- }
-}
-
-static void
-FileList_add(FileList fl, char *file)
-{
- FileList_ensureCapacity(fl, fl->size+1);
- fl->files[fl->size++] = file;
-}
-
-static void
-FileList_addSubstring(FileList fl, const char *beg, int len)
-{
- char *filename = (char *) JLI_MemAlloc(len+1);
- memcpy(filename, beg, len);
- filename[len] = '\0';
- FileList_ensureCapacity(fl, fl->size+1);
- fl->files[fl->size++] = filename;
-}
-
-static char *
-FileList_join(FileList fl, char sep)
-{
- int i;
- int size;
- char *path;
- char *p;
- for (i = 0, size = 1; i < fl->size; i++)
- size += strlen(fl->files[i]) + 1;
-
- path = JLI_MemAlloc(size);
-
- for (i = 0, p = path; i < fl->size; i++) {
- int len = strlen(fl->files[i]);
- if (i > 0) *p++ = sep;
- memcpy(p, fl->files[i], len);
- p += len;
- }
- *p = '\0';
-
- return path;
-}
-
-static FileList
-FileList_split(const char *path, char sep)
-{
- const char *p, *q;
- int len = strlen(path);
- int count;
- FileList fl;
- for (count = 1, p = path; p < path + len; p++)
- count += (*p == sep);
- fl = FileList_new(count);
- for (p = path;;) {
- for (q = p; q <= path + len; q++) {
- if (*q == sep || *q == '\0') {
- FileList_addSubstring(fl, p, q - p);
- if (*q == '\0')
- return fl;
- p = q + 1;
- }
- }
- }
-}
-
-static int
-isJarFileName(const char *filename)
-{
- int len = strlen(filename);
- return (len >= 4) &&
- (filename[len - 4] == '.') &&
- (equal(filename + len - 3, "jar") ||
- equal(filename + len - 3, "JAR")) &&
- /* Paranoia: Maybe filename is "DIR:foo.jar" */
- (strchr(filename, PATH_SEPARATOR) == NULL);
-}
-
-static char *
-wildcardConcat(const char *wildcard, const char *basename)
-{
- int wildlen = strlen(wildcard);
- int baselen = strlen(basename);
- char *filename = (char *) JLI_MemAlloc(wildlen + baselen);
- /* Replace the trailing '*' with basename */
- memcpy(filename, wildcard, wildlen-1);
- memcpy(filename+wildlen-1, basename, baselen+1);
- return filename;
-}
-
-static FileList
-wildcardFileList(const char *wildcard)
-{
- const char *basename;
- FileList fl = FileList_new(16);
- WildcardIterator it = WildcardIterator_for(wildcard);
- if (it == NULL) {
- FileList_free(fl);
- return NULL;
- }
- while ((basename = WildcardIterator_next(it)) != NULL)
- if (isJarFileName(basename))
- FileList_add(fl, wildcardConcat(wildcard, basename));
- WildcardIterator_close(it);
- return fl;
-}
-
-static int
-isWildcard(const char *filename)
-{
- int len = strlen(filename);
- return (len > 0) &&
- (filename[len - 1] == '*') &&
- (len == 1 || IS_FILE_SEPARATOR(filename[len - 2])) &&
- (! exists(filename));
-}
-
-static void
-FileList_expandWildcards(FileList fl)
-{
- int i, j;
- for (i = 0; i < fl->size; i++) {
- if (isWildcard(fl->files[i])) {
- FileList expanded = wildcardFileList(fl->files[i]);
- if (expanded != NULL && expanded->size > 0) {
- JLI_MemFree(fl->files[i]);
- FileList_ensureCapacity(fl, fl->size + expanded->size);
- for (j = fl->size - 1; j >= i+1; j--)
- fl->files[j+expanded->size-1] = fl->files[j];
- for (j = 0; j < expanded->size; j++)
- fl->files[i+j] = expanded->files[j];
- i += expanded->size - 1;
- fl->size += expanded->size - 1;
- /* fl expropriates expanded's elements. */
- expanded->size = 0;
- }
- FileList_free(expanded);
- }
- }
-}
-
-const char *
-JLI_WildcardExpandClasspath(const char *classpath)
-{
- char *expanded;
- FileList fl;
-
- if (strchr(classpath, '*') == NULL)
- return classpath;
- fl = FileList_split(classpath, PATH_SEPARATOR);
- FileList_expandWildcards(fl);
- expanded = FileList_join(fl, PATH_SEPARATOR);
- FileList_free(fl);
- if (getenv("_JAVA_LAUNCHER_DEBUG") != 0)
- printf("Expanded wildcards:\n"
- " before: \"%s\"\n"
- " after : \"%s\"\n",
- classpath, expanded);
- return expanded;
-}
-
-#ifdef DEBUG_WILDCARD
-static void
-wildcardExpandArgv(const char ***argv)
-{
- int i;
- for (i = 0; (*argv)[i]; i++) {
- if (equal((*argv)[i], "-cp") ||
- equal((*argv)[i], "-classpath")) {
- i++;
- (*argv)[i] = wildcardExpandClasspath((*argv)[i]);
- }
- }
-}
-
-static void
-debugPrintArgv(char *argv[])
-{
- int i;
- putchar('[');
- for (i = 0; argv[i]; i++) {
- if (i > 0) printf(", ");
- printf("\"%s\"", argv[i]);
- }
- printf("]\n");
-}
-
-int
-main(int argc, char *argv[])
-{
- argv[0] = "java";
- wildcardExpandArgv((const char***)&argv);
- debugPrintArgv(argv);
- /* execvp("java", argv); */
- return 0;
-}
-#endif /* DEBUG_WILDCARD */
-
-/* Cute little perl prototype implementation....
-
-my $sep = ($^O =~ /^(Windows|cygwin)/) ? ";" : ":";
-
-sub expand($) {
- opendir DIR, $_[0] or return $_[0];
- join $sep, map {"$_[0]/$_"} grep {/\.(jar|JAR)$/} readdir DIR;
-}
-
-sub munge($) {
- join $sep,
- map {(! -r $_ and s/[\/\\]+\*$//) ? expand $_ : $_} split $sep, $_[0];
-}
-
-for (my $i = 0; $i < @ARGV - 1; $i++) {
- $ARGV[$i+1] = munge $ARGV[$i+1] if $ARGV[$i] =~ /^-c(p|lasspath)$/;
-}
-
-$ENV{CLASSPATH} = munge $ENV{CLASSPATH} if exists $ENV{CLASSPATH};
-@ARGV = ("java", @ARGV);
-print "@ARGV\n";
-exec @ARGV;
-
-*/
diff --git a/hotspot/src/share/tools/launcher/wildcard.h b/hotspot/src/share/tools/launcher/wildcard.h
deleted file mode 100644
index 5cdd9312cd4..00000000000
--- a/hotspot/src/share/tools/launcher/wildcard.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 1999, 2010, 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.
- *
- */
-
-#ifndef WILDCARD_H_
-#define WILDCARD_H_
-
-#ifdef EXPAND_CLASSPATH_WILDCARDS
-const char *JLI_WildcardExpandClasspath(const char *classpath);
-#else
-#define JLI_WildcardExpandClasspath(s) (s)
-#endif
-
-#endif /* include guard */
From a788347b73dcbaaba6ee338601490101d5f6af19 Mon Sep 17 00:00:00 2001
From: Marcus Lagergren
Date: Tue, 7 May 2013 14:36:57 +0200
Subject: [PATCH 021/147] 8013913: Removed Source field from all nodes except
FunctionNode in order to save footprint
Reviewed-by: jlaskey, attila
---
.../api/scripting/NashornScriptEngine.java | 3 +-
.../jdk/nashorn/internal/codegen/Attr.java | 3 +-
.../internal/codegen/CodeGenerator.java | 13 +-
.../internal/codegen/FinalizeTypes.java | 16 +--
.../internal/codegen/FoldConstants.java | 51 ++++---
.../jdk/nashorn/internal/codegen/Lower.java | 42 +++---
.../nashorn/internal/codegen/Splitter.java | 4 +-
.../jdk/nashorn/internal/ir/AccessNode.java | 6 +-
.../src/jdk/nashorn/internal/ir/BaseNode.java | 6 +-
.../jdk/nashorn/internal/ir/BinaryNode.java | 6 +-
.../src/jdk/nashorn/internal/ir/Block.java | 11 +-
.../jdk/nashorn/internal/ir/BreakNode.java | 6 +-
.../nashorn/internal/ir/BreakableNode.java | 6 +-
.../src/jdk/nashorn/internal/ir/CallNode.java | 6 +-
.../src/jdk/nashorn/internal/ir/CaseNode.java | 6 +-
.../jdk/nashorn/internal/ir/CatchNode.java | 8 +-
.../jdk/nashorn/internal/ir/ContinueNode.java | 6 +-
.../jdk/nashorn/internal/ir/EmptyNode.java | 6 +-
.../jdk/nashorn/internal/ir/ExecuteNode.java | 8 +-
.../src/jdk/nashorn/internal/ir/ForNode.java | 6 +-
.../jdk/nashorn/internal/ir/FunctionNode.java | 17 ++-
.../jdk/nashorn/internal/ir/IdentNode.java | 6 +-
.../src/jdk/nashorn/internal/ir/IfNode.java | 6 +-
.../jdk/nashorn/internal/ir/IndexNode.java | 6 +-
.../jdk/nashorn/internal/ir/LabelNode.java | 6 +-
.../nashorn/internal/ir/LexicalContext.java | 18 +--
.../internal/ir/LexicalContextNode.java | 6 +-
.../nashorn/internal/ir/LineNumberNode.java | 6 +-
.../jdk/nashorn/internal/ir/LiteralNode.java | 102 ++++++-------
.../src/jdk/nashorn/internal/ir/Location.java | 134 ------------------
.../src/jdk/nashorn/internal/ir/LoopNode.java | 6 +-
nashorn/src/jdk/nashorn/internal/ir/Node.java | 87 ++++++++++--
.../jdk/nashorn/internal/ir/ObjectNode.java | 6 +-
.../jdk/nashorn/internal/ir/PropertyNode.java | 6 +-
.../jdk/nashorn/internal/ir/ReturnNode.java | 6 +-
.../jdk/nashorn/internal/ir/RuntimeNode.java | 11 +-
.../jdk/nashorn/internal/ir/SplitNode.java | 2 +-
.../jdk/nashorn/internal/ir/SwitchNode.java | 6 +-
.../jdk/nashorn/internal/ir/TernaryNode.java | 6 +-
.../jdk/nashorn/internal/ir/ThrowNode.java | 7 +-
.../src/jdk/nashorn/internal/ir/TryNode.java | 6 +-
.../jdk/nashorn/internal/ir/UnaryNode.java | 12 +-
.../src/jdk/nashorn/internal/ir/VarNode.java | 11 +-
.../jdk/nashorn/internal/ir/WhileNode.java | 6 +-
.../src/jdk/nashorn/internal/ir/WithNode.java | 8 +-
.../nashorn/internal/ir/debug/JSONWriter.java | 2 +-
.../nashorn/internal/objects/NativeDebug.java | 1 -
.../internal/parser/AbstractParser.java | 14 +-
.../nashorn/internal/parser/JSONParser.java | 14 +-
.../jdk/nashorn/internal/parser/Parser.java | 125 ++++++++--------
.../RecompilableScriptFunctionData.java | 4 +
.../internal/runtime/ScriptObject.java | 2 -
.../runtime/arrays/ArrayLikeIterator.java | 1 -
.../runtime/linker/LinkerCallSite.java | 5 +-
nashorn/src/jdk/nashorn/tools/Shell.java | 1 -
55 files changed, 366 insertions(+), 515 deletions(-)
delete mode 100644 nashorn/src/jdk/nashorn/internal/ir/Location.java
diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java
index 197a6da472f..283e36e9e33 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java
@@ -78,7 +78,6 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
this(factory, DEFAULT_OPTIONS, appLoader);
}
- @SuppressWarnings("LeakingThisInConstructor")
NashornScriptEngine(final NashornScriptEngineFactory factory, final String[] args, final ClassLoader appLoader) {
this.factory = factory;
final Options options = new Options("nashorn");
@@ -102,7 +101,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
});
// create new global object
- this.global = createNashornGlobal();
+ this.global = createNashornGlobal();
// set the default engine scope for the default context
context.setBindings(new ScriptObjectMirror(global, global), ScriptContext.ENGINE_SCOPE);
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java
index d5c9ef07a60..a381e58d7aa 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java
@@ -435,7 +435,6 @@ final class Attr extends NodeOperatorVisitor {
final IdentNode callee = compilerConstant(CALLEE);
VarNode selfInit =
new VarNode(
- newFunctionNode.getSource(),
newFunctionNode.getToken(),
newFunctionNode.getFinish(),
newFunctionNode.getIdent(),
@@ -531,6 +530,7 @@ final class Attr extends NodeOperatorVisitor {
setBlockScope(name, symbol);
if (symbol != null && !identNode.isInitializedHere()) {
+
symbol.increaseUseCount();
}
addLocalUse(identNode.getName());
@@ -914,7 +914,6 @@ final class Attr extends NodeOperatorVisitor {
final FunctionNode functionNode = getLexicalContext().getCurrentFunction();
return (IdentNode)
new IdentNode(
- functionNode.getSource(),
functionNode.getToken(),
functionNode.getFinish(),
cc.symbolName()).
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
index 8f5b3154d25..97219e3db8a 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
@@ -261,14 +261,15 @@ final class CodeGenerator extends NodeOperatorVisitor {
return method.load(symbol);
}
- final String name = symbol.getName();
+ final String name = symbol.getName();
+ final Source source = getLexicalContext().getCurrentFunction().getSource();
if (CompilerConstants.__FILE__.name().equals(name)) {
- return method.load(identNode.getSource().getName());
+ return method.load(source.getName());
} else if (CompilerConstants.__DIR__.name().equals(name)) {
- return method.load(identNode.getSource().getBase());
+ return method.load(source.getBase());
} else if (CompilerConstants.__LINE__.name().equals(name)) {
- return method.load(identNode.getSource().getLine(identNode.position())).convert(Type.OBJECT);
+ return method.load(source.getLine(identNode.position())).convert(Type.OBJECT);
} else {
assert identNode.getSymbol().isScope() : identNode + " is not in scope!";
@@ -2005,8 +2006,9 @@ final class CodeGenerator extends NodeOperatorVisitor {
public boolean enterThrowNode(final ThrowNode throwNode) {
method._new(ECMAException.class).dup();
+ final Source source = getLexicalContext().getCurrentFunction().getSource();
+
final Node expression = throwNode.getExpression();
- final Source source = throwNode.getSource();
final int position = throwNode.position();
final int line = source.getLine(position);
final int column = source.getColumn(position);
@@ -3013,7 +3015,6 @@ final class CodeGenerator extends NodeOperatorVisitor {
return;
}
- @SuppressWarnings("resource")
final PrintWriter out = compiler.getEnv().getErr();
out.println("[BLOCK in '" + ident + "']");
if (!block.printSymbols(out)) {
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java
index 895b344e3e8..1b6e3c161df 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java
@@ -773,7 +773,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
private Node convert(final Node node, final Type to) {
assert !to.isUnknown() : "unknown type for " + node + " class=" + node.getClass();
assert node != null : "node is null";
- assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction() + " " + node.getSource();
+ assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction();
assert node.tokenType() != TokenType.CONVERT : "assert convert in convert " + node + " in " + getLexicalContext().getCurrentFunction();
final Type from = node.getType();
@@ -798,7 +798,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
assert node instanceof TypeOverride;
return setTypeOverride(node, to);
}
- resultNode = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.CONVERT), node);
+ resultNode = new UnaryNode(Token.recast(node.getToken(), TokenType.CONVERT), node);
}
LOG.info("CONVERT('", node, "', ", to, ") => '", resultNode, "'");
@@ -813,7 +813,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
private static Node discard(final Node node) {
if (node.getSymbol() != null) {
- final Node discard = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.DISCARD), node);
+ final Node discard = new UnaryNode(Token.recast(node.getToken(), TokenType.DISCARD), node);
//discard never has a symbol in the discard node - then it would be a nop
assert !node.isTerminal();
return discard;
@@ -881,15 +881,15 @@ final class FinalizeTypes extends NodeOperatorVisitor {
LiteralNode> literalNode = null;
if (type.isString()) {
- literalNode = LiteralNode.newInstance(source, token, finish, JSType.toString(value));
+ literalNode = LiteralNode.newInstance(token, finish, JSType.toString(value));
} else if (type.isBoolean()) {
- literalNode = LiteralNode.newInstance(source, token, finish, JSType.toBoolean(value));
+ literalNode = LiteralNode.newInstance(token, finish, JSType.toBoolean(value));
} else if (type.isInteger()) {
- literalNode = LiteralNode.newInstance(source, token, finish, JSType.toInt32(value));
+ literalNode = LiteralNode.newInstance(token, finish, JSType.toInt32(value));
} else if (type.isLong()) {
- literalNode = LiteralNode.newInstance(source, token, finish, JSType.toLong(value));
+ literalNode = LiteralNode.newInstance(token, finish, JSType.toLong(value));
} else if (type.isNumber() || parent.getType().isNumeric() && !parent.getType().isNumber()) {
- literalNode = LiteralNode.newInstance(source, token, finish, JSType.toNumber(value));
+ literalNode = LiteralNode.newInstance(token, finish, JSType.toNumber(value));
}
if (literalNode != null) {
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
index 03accb4b517..92286c2bf63 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
@@ -41,7 +41,6 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.runtime.DebugLogger;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ScriptRuntime;
-import jdk.nashorn.internal.runtime.Source;
/**
* Simple constant folding pass, executed before IR is starting to be lowered.
@@ -112,13 +111,11 @@ final class FoldConstants extends NodeVisitor {
*/
abstract static class ConstantEvaluator {
protected T parent;
- protected final Source source;
protected final long token;
protected final int finish;
protected ConstantEvaluator(final T parent) {
this.parent = parent;
- this.source = parent.getSource();
this.token = parent.getToken();
this.finish = parent.getFinish();
}
@@ -152,23 +149,23 @@ final class FoldConstants extends NodeVisitor {
switch (parent.tokenType()) {
case ADD:
if (rhsInteger) {
- literalNode = LiteralNode.newInstance(source, token, finish, rhs.getInt32());
+ literalNode = LiteralNode.newInstance(token, finish, rhs.getInt32());
} else {
- literalNode = LiteralNode.newInstance(source, token, finish, rhs.getNumber());
+ literalNode = LiteralNode.newInstance(token, finish, rhs.getNumber());
}
break;
case SUB:
if (rhsInteger && rhs.getInt32() != 0) { // @see test/script/basic/minuszero.js
- literalNode = LiteralNode.newInstance(source, token, finish, -rhs.getInt32());
+ literalNode = LiteralNode.newInstance(token, finish, -rhs.getInt32());
} else {
- literalNode = LiteralNode.newInstance(source, token, finish, -rhs.getNumber());
+ literalNode = LiteralNode.newInstance(token, finish, -rhs.getNumber());
}
break;
case NOT:
- literalNode = LiteralNode.newInstance(source, token, finish, !rhs.getBoolean());
+ literalNode = LiteralNode.newInstance(token, finish, !rhs.getBoolean());
break;
case BIT_NOT:
- literalNode = LiteralNode.newInstance(source, token, finish, ~rhs.getInt32());
+ literalNode = LiteralNode.newInstance(token, finish, ~rhs.getInt32());
break;
default:
return null;
@@ -234,7 +231,7 @@ final class FoldConstants extends NodeVisitor {
break;
}
assert res instanceof CharSequence : res + " was not a CharSequence, it was a " + res.getClass();
- return LiteralNode.newInstance(source, token, finish, res.toString());
+ return LiteralNode.newInstance(token, finish, res.toString());
}
return null;
case MUL:
@@ -247,33 +244,33 @@ final class FoldConstants extends NodeVisitor {
value = lhs.getNumber() - rhs.getNumber();
break;
case SHR:
- return LiteralNode.newInstance(source, token, finish, (lhs.getInt32() >>> rhs.getInt32()) & JSType.MAX_UINT);
+ return LiteralNode.newInstance(token, finish, (lhs.getInt32() >>> rhs.getInt32()) & JSType.MAX_UINT);
case SAR:
- return LiteralNode.newInstance(source, token, finish, lhs.getInt32() >> rhs.getInt32());
+ return LiteralNode.newInstance(token, finish, lhs.getInt32() >> rhs.getInt32());
case SHL:
- return LiteralNode.newInstance(source, token, finish, lhs.getInt32() << rhs.getInt32());
+ return LiteralNode.newInstance(token, finish, lhs.getInt32() << rhs.getInt32());
case BIT_XOR:
- return LiteralNode.newInstance(source, token, finish, lhs.getInt32() ^ rhs.getInt32());
+ return LiteralNode.newInstance(token, finish, lhs.getInt32() ^ rhs.getInt32());
case BIT_AND:
- return LiteralNode.newInstance(source, token, finish, lhs.getInt32() & rhs.getInt32());
+ return LiteralNode.newInstance(token, finish, lhs.getInt32() & rhs.getInt32());
case BIT_OR:
- return LiteralNode.newInstance(source, token, finish, lhs.getInt32() | rhs.getInt32());
+ return LiteralNode.newInstance(token, finish, lhs.getInt32() | rhs.getInt32());
case GE:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.GE(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.GE(lhs.getObject(), rhs.getObject()));
case LE:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.LE(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.LE(lhs.getObject(), rhs.getObject()));
case GT:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.GT(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.GT(lhs.getObject(), rhs.getObject()));
case LT:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.LT(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.LT(lhs.getObject(), rhs.getObject()));
case NE:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.NE(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.NE(lhs.getObject(), rhs.getObject()));
case NE_STRICT:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.NE_STRICT(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.NE_STRICT(lhs.getObject(), rhs.getObject()));
case EQ:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.EQ(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.EQ(lhs.getObject(), rhs.getObject()));
case EQ_STRICT:
- return LiteralNode.newInstance(source, token, finish, ScriptRuntime.EQ_STRICT(lhs.getObject(), rhs.getObject()));
+ return LiteralNode.newInstance(token, finish, ScriptRuntime.EQ_STRICT(lhs.getObject(), rhs.getObject()));
default:
return null;
}
@@ -282,12 +279,12 @@ final class FoldConstants extends NodeVisitor {
isLong &= value != 0.0 && JSType.isRepresentableAsLong(value);
if (isInteger) {
- return LiteralNode.newInstance(source, token, finish, JSType.toInt32(value));
+ return LiteralNode.newInstance(token, finish, JSType.toInt32(value));
} else if (isLong) {
- return LiteralNode.newInstance(source, token, finish, JSType.toLong(value));
+ return LiteralNode.newInstance(token, finish, JSType.toLong(value));
}
- return LiteralNode.newInstance(source, token, finish, value);
+ return LiteralNode.newInstance(token, finish, value);
}
}
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java
index d6209e4fd01..6f55841ebc9 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java
@@ -118,8 +118,9 @@ final class Lower extends NodeOperatorVisitor {
@Override
public boolean enterBlock(final Block block) {
final LexicalContext lc = getLexicalContext();
- if (lc.isFunctionBody() && lc.getCurrentFunction().isProgram() && !lc.getCurrentFunction().hasDeclaredFunctions()) {
- new ExecuteNode(block.getSource(), block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this);
+ final FunctionNode function = lc.getCurrentFunction();
+ if (lc.isFunctionBody() && function.isProgram() && !function.hasDeclaredFunctions()) {
+ new ExecuteNode(block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this);
}
return true;
}
@@ -137,7 +138,6 @@ final class Lower extends NodeOperatorVisitor {
final FunctionNode currentFunction = getLexicalContext().getCurrentFunction();
final boolean isProgram = currentFunction.isProgram();
final ReturnNode returnNode = new ReturnNode(
- currentFunction.getSource(),
currentFunction.getToken(),
currentFunction.getFinish(),
isProgram ?
@@ -193,7 +193,6 @@ final class Lower extends NodeOperatorVisitor {
if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) {
node = executeNode.setExpression(
new BinaryNode(
- executeNode.getSource(),
Token.recast(
executeNode.getToken(),
TokenType.ASSIGN),
@@ -284,17 +283,16 @@ final class Lower extends NodeOperatorVisitor {
}
private Block catchAllBlock(final TryNode tryNode) {
- final Source source = tryNode.getSource();
final long token = tryNode.getToken();
final int finish = tryNode.getFinish();
- final IdentNode exception = new IdentNode(source, token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all"));
+ final IdentNode exception = new IdentNode(token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all"));
- final Block catchBody = new Block(source, token, finish, new ThrowNode(source, token, finish, new IdentNode(exception))).
+ final Block catchBody = new Block(token, finish, new ThrowNode(token, finish, new IdentNode(exception))).
setIsTerminal(getLexicalContext(), true); //ends with throw, so terminal
- final CatchNode catchAllNode = new CatchNode(source, token, finish, new IdentNode(exception), null, catchBody);
- final Block catchAllBlock = new Block(source, token, finish, catchAllNode);
+ final CatchNode catchAllNode = new CatchNode(token, finish, new IdentNode(exception), null, catchBody);
+ final Block catchAllBlock = new Block(token, finish, catchAllNode);
//catchallblock -> catchallnode (catchnode) -> exception -> throw
@@ -303,7 +301,7 @@ final class Lower extends NodeOperatorVisitor {
private IdentNode compilerConstant(final CompilerConstants cc) {
final FunctionNode functionNode = getLexicalContext().getCurrentFunction();
- return new IdentNode(functionNode.getSource(), functionNode.getToken(), functionNode.getFinish(), cc.symbolName());
+ return new IdentNode(functionNode.getToken(), functionNode.getFinish(), cc.symbolName());
}
private static boolean isTerminal(final List statements) {
@@ -318,7 +316,6 @@ final class Lower extends NodeOperatorVisitor {
* @return new try node after splicing finally code (same if nop)
*/
private Node spliceFinally(final TryNode tryNode, final List rethrows, final Block finallyBody) {
- final Source source = tryNode.getSource();
final int finish = tryNode.getFinish();
assert tryNode.getFinallyBody() == null;
@@ -345,7 +342,7 @@ final class Lower extends NodeOperatorVisitor {
if (!isTerminal(newStatements)) {
newStatements.add(throwNode);
}
- return new Block(source, throwNode.getToken(), throwNode.getFinish(), newStatements);
+ return new Block(throwNode.getToken(), throwNode.getFinish(), newStatements);
}
return throwNode;
}
@@ -370,7 +367,7 @@ final class Lower extends NodeOperatorVisitor {
//we need to evaluate the result of the return in case it is complex while
//still in the try block, store it in a result value and return it afterwards
resultNode = new IdentNode(Lower.this.compilerConstant(RETURN));
- newStatements.add(new ExecuteNode(new BinaryNode(source, Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
+ newStatements.add(new ExecuteNode(new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
} else {
resultNode = null;
}
@@ -380,7 +377,7 @@ final class Lower extends NodeOperatorVisitor {
newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode));
}
- return new ExecuteNode(new Block(source, returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements));
+ return new ExecuteNode(new Block(returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements));
}
private Node copy(final Node endpoint, final Node targetNode) {
@@ -389,7 +386,7 @@ final class Lower extends NodeOperatorVisitor {
if (!isTerminal(newStatements)) {
newStatements.add(endpoint);
}
- return new ExecuteNode(new Block(source, endpoint.getToken(), finish, newStatements));
+ return new ExecuteNode(new Block(endpoint.getToken(), finish, newStatements));
}
return endpoint;
}
@@ -451,7 +448,7 @@ final class Lower extends NodeOperatorVisitor {
if (tryNode.getCatchBlocks().isEmpty()) {
newTryNode = tryNode.setFinallyBody(null);
} else {
- Block outerBody = new Block(tryNode.getSource(), tryNode.getToken(), tryNode.getFinish(), new ArrayList(Arrays.asList(tryNode.setFinallyBody(null))));
+ Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), new ArrayList(Arrays.asList(tryNode.setFinallyBody(null))));
newTryNode = tryNode.setBody(outerBody).setCatchBlocks(null);
}
@@ -468,19 +465,19 @@ final class Lower extends NodeOperatorVisitor {
public Node leaveVarNode(final VarNode varNode) {
addStatement(varNode);
if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && getLexicalContext().getCurrentFunction().isProgram()) {
- new ExecuteNode(varNode.getSource(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
+ new ExecuteNode(varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
}
return varNode;
}
@Override
public Node leaveWhileNode(final WhileNode whileNode) {
- final Node test = whileNode.getTest();
+ final Node test = whileNode.getTest();
final Block body = whileNode.getBody();
if (conservativeAlwaysTrue(test)) {
//turn it into a for node without a test.
- final ForNode forNode = (ForNode)new ForNode(whileNode.getSource(), whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this);
+ final ForNode forNode = (ForNode)new ForNode(whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this);
getLexicalContext().replace(whileNode, forNode);
return forNode;
}
@@ -525,11 +522,12 @@ final class Lower extends NodeOperatorVisitor {
* @param node a node
* @return eval location
*/
- private static String evalLocation(final IdentNode node) {
+ private String evalLocation(final IdentNode node) {
+ final Source source = getLexicalContext().getCurrentFunction().getSource();
return new StringBuilder().
- append(node.getSource().getName()).
+ append(source.getName()).
append('#').
- append(node.getSource().getLine(node.position())).
+ append(source.getLine(node.position())).
append("").
toString();
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java
index 8049473c87b..e86a516e0f8 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java
@@ -42,7 +42,6 @@ import jdk.nashorn.internal.ir.Node;
import jdk.nashorn.internal.ir.SplitNode;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.runtime.DebugLogger;
-import jdk.nashorn.internal.runtime.Source;
import jdk.nashorn.internal.runtime.options.Options;
/**
@@ -221,12 +220,11 @@ final class Splitter extends NodeVisitor {
* @return New split node.
*/
private SplitNode createBlockSplitNode(final Block parent, final FunctionNode function, final List statements, final long weight) {
- final Source source = parent.getSource();
final long token = parent.getToken();
final int finish = parent.getFinish();
final String name = function.uniqueName(SPLIT_PREFIX.symbolName());
- final Block newBlock = new Block(source, token, finish, statements);
+ final Block newBlock = new Block(token, finish, statements);
return new SplitNode(name, newBlock, compiler.findUnit(weight + WeighNodes.FUNCTION_WEIGHT));
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java b/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java
index 2f739bf03a1..a179056598a 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of a property access (period operator.)
@@ -41,14 +40,13 @@ public final class AccessNode extends BaseNode {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param base base node
* @param property property
*/
- public AccessNode(final Source source, final long token, final int finish, final Node base, final IdentNode property) {
- super(source, token, finish, base, false, false);
+ public AccessNode(final long token, final int finish, final Node base, final IdentNode property) {
+ super(token, finish, base, false, false);
this.property = property.setIsPropertyName();
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java b/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java
index 5e5bfb13c59..a1b7c0eed7d 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java
@@ -29,7 +29,6 @@ import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Immutable;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR base for accessing/indexing nodes.
@@ -50,15 +49,14 @@ public abstract class BaseNode extends Node implements FunctionCall, TypeOverrid
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param base base node
* @param isFunction is this a function
* @param hasCallSiteType does this access have a callsite type
*/
- public BaseNode(final Source source, final long token, final int finish, final Node base, final boolean isFunction, final boolean hasCallSiteType) {
- super(source, token, base.getStart(), finish);
+ public BaseNode(final long token, final int finish, final Node base, final boolean isFunction, final boolean hasCallSiteType) {
+ super(token, base.getStart(), finish);
this.base = base;
this.isFunction = isFunction;
this.hasCallSiteType = hasCallSiteType;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java
index 28df8edfcc8..61454fef0a1 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java
@@ -29,7 +29,6 @@ import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.parser.TokenType;
-import jdk.nashorn.internal.runtime.Source;
/**
* BinaryNode nodes represent two operand operations.
@@ -44,13 +43,12 @@ public final class BinaryNode extends Node implements Assignment {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param lhs left hand side
* @param rhs right hand side
*/
- public BinaryNode(final Source source, final long token, final Node lhs, final Node rhs) {
- super(source, token, lhs.getStart(), rhs.getFinish());
+ public BinaryNode(final long token, final Node lhs, final Node rhs) {
+ super(token, lhs.getStart(), rhs.getFinish());
this.lhs = lhs;
this.rhs = rhs;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/Block.java b/nashorn/src/jdk/nashorn/internal/ir/Block.java
index 15a00869f0a..9e5d69a793d 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/Block.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/Block.java
@@ -36,7 +36,6 @@ import java.util.Map;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for a list of statements and functions. All provides the
@@ -77,13 +76,12 @@ public class Block extends BreakableNode implements Flags {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param statements statements
*/
- public Block(final Source source, final long token, final int finish, final Node... statements) {
- super(source, token, finish, new Label("block_break"));
+ public Block(final long token, final int finish, final Node... statements) {
+ super(token, finish, new Label("block_break"));
this.statements = Arrays.asList(statements);
this.symbols = new LinkedHashMap<>();
@@ -94,13 +92,12 @@ public class Block extends BreakableNode implements Flags {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param statements statements
*/
- public Block(final Source source, final long token, final int finish, final List statements) {
- this(source, token, finish, statements.toArray(new Node[statements.size()]));
+ public Block(final long token, final int finish, final List statements) {
+ this(token, finish, statements.toArray(new Node[statements.size()]));
}
private Block(final Block block, final int finish, final List statements, final int flags, final Map symbols) {
diff --git a/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java b/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java
index f0966b4692b..630c1ab619e 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for {@code break} statements.
@@ -40,13 +39,12 @@ public final class BreakNode extends Node {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param label label for break or null if none
*/
- public BreakNode(final Source source, final long token, final int finish, final IdentNode label) {
- super(source, token, finish);
+ public BreakNode(final long token, final int finish, final IdentNode label) {
+ super(token, finish);
this.label = label;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/BreakableNode.java b/nashorn/src/jdk/nashorn/internal/ir/BreakableNode.java
index 3662bfa774e..f433dc4d75f 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/BreakableNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/BreakableNode.java
@@ -30,7 +30,6 @@ import java.util.List;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
-import jdk.nashorn.internal.runtime.Source;
/**
* This class represents a node from which control flow can execute
@@ -45,13 +44,12 @@ public abstract class BreakableNode extends LexicalContextNode {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param breakLabel break label
*/
- protected BreakableNode(final Source source, final long token, final int finish, final Label breakLabel) {
- super(source, token, finish);
+ protected BreakableNode(final long token, final int finish, final Label breakLabel) {
+ super(token, finish);
this.breakLabel = breakLabel;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java
index 9a730aa862f..71504abc572 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java
@@ -31,7 +31,6 @@ import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Ignore;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for a function call.
@@ -137,14 +136,13 @@ public final class CallNode extends LexicalContextNode implements TypeOverride args) {
- super(source, token, finish);
+ public CallNode(final long token, final int finish, final Node function, final List args) {
+ super(token, finish);
this.function = function;
this.args = args;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java
index 237536cc490..8a438f8fb71 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of CASE clause.
@@ -48,14 +47,13 @@ public final class CaseNode extends Node {
/**
* Constructors
*
- * @param source the source
* @param token token
* @param finish finish
* @param test case test node, can be any node in JavaScript
* @param body case body
*/
- public CaseNode(final Source source, final long token, final int finish, final Node test, final Block body) {
- super(source, token, finish);
+ public CaseNode(final long token, final int finish, final Node test, final Block body) {
+ super(token, finish);
this.test = test;
this.body = body;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java
index e7d231e8d82..993b996a6a2 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of a catch clause.
@@ -46,16 +45,14 @@ public final class CatchNode extends Node {
/**
* Constructors
*
- * @param source the source
* @param token token
* @param finish finish
* @param exception variable name of exception
* @param exceptionCondition exception condition
* @param body catch body
*/
- public CatchNode(final Source source, final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) {
- super(source, token, finish);
-
+ public CatchNode(final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) {
+ super(token, finish);
this.exception = exception;
this.exceptionCondition = exceptionCondition;
this.body = body;
@@ -63,7 +60,6 @@ public final class CatchNode extends Node {
private CatchNode(final CatchNode catchNode, final IdentNode exception, final Node exceptionCondition, final Block body) {
super(catchNode);
-
this.exception = exception;
this.exceptionCondition = exceptionCondition;
this.body = body;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java b/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java
index c8cc309d51e..2abdc7d01a5 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for CONTINUE statements.
@@ -40,13 +39,12 @@ public class ContinueNode extends Node {
/**
* Constructor
*
- * @param source source code
* @param token token
* @param finish finish
* @param label label for break or null if none
*/
- public ContinueNode(final Source source, final long token, final int finish, final IdentNode label) {
- super(source, token, finish);
+ public ContinueNode(final long token, final int finish, final IdentNode label) {
+ super(token, finish);
this.label = label;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java b/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java
index 67516127057..06a4f66f8db 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for an empty statement.
@@ -47,12 +46,11 @@ public final class EmptyNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
*/
- public EmptyNode(final Source source, final long token, final int finish) {
- super(source, token, finish);
+ public EmptyNode(final long token, final int finish) {
+ super(token, finish);
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java b/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java
index f6dd7d1bf8c..8a9e27dd75e 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for executing bare expressions. Basically, an expression
@@ -42,13 +41,12 @@ public final class ExecuteNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param expression the expression to execute
*/
- public ExecuteNode(final Source source, final long token, final int finish, final Node expression) {
- super(source, token, finish);
+ public ExecuteNode(final long token, final int finish, final Node expression) {
+ super(token, finish);
this.expression = expression;
}
@@ -63,7 +61,7 @@ public final class ExecuteNode extends Node {
* @param expression an expression to wrap, from which source, tokens and finish are also inherited
*/
public ExecuteNode(final Node expression) {
- super(expression.getSource(), expression.getToken(), expression.getFinish());
+ super(expression.getToken(), expression.getFinish());
this.expression = expression;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/ForNode.java b/nashorn/src/jdk/nashorn/internal/ir/ForNode.java
index 057b8464ac7..17a63a66495 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/ForNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/ForNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representing a FOR statement.
@@ -57,7 +56,6 @@ public final class ForNode extends LoopNode {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param init init
@@ -66,8 +64,8 @@ public final class ForNode extends LoopNode {
* @param modify modify
* @param flags flags
*/
- public ForNode(final Source source, final long token, final int finish, final Node init, final Node test, final Block body, final Node modify, final int flags) {
- super(source, token, finish, test, body, false);
+ public ForNode(final long token, final int finish, final Node init, final Node test, final Block body, final Node modify, final int flags) {
+ super(token, finish, test, body, false);
this.init = init;
this.modify = modify;
this.flags = flags;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java
index dc11771de3b..728d81cbca4 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java
@@ -86,6 +86,8 @@ public final class FunctionNode extends LexicalContextNode implements Flags parameters,
final FunctionNode.Kind kind,
final int flags) {
- super(source, token, finish);
+ super(token, finish);
+ this.source = source;
this.ident = ident;
this.name = name;
this.kind = kind;
@@ -265,6 +268,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags ]");
diff --git a/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java b/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java
index c4d78224271..dffdaae8480 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/LexicalContextNode.java
@@ -25,7 +25,6 @@
package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* Superclass for nodes that can be part of the lexical context
@@ -35,12 +34,11 @@ public abstract class LexicalContextNode extends Node {
/**
* Constructor
*
- * @param source source
* @param token token
* @param finish finish
*/
- protected LexicalContextNode(final Source source, final long token, final int finish) {
- super(source, token, finish);
+ protected LexicalContextNode(final long token, final int finish) {
+ super(token, finish);
}
/**
diff --git a/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java b/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java
index 63f04594451..59bfb0c564a 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.parser.Token;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR Node representing a line number
@@ -41,12 +40,11 @@ public final class LineNumberNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param lineNumber the line number
*/
- public LineNumberNode(final Source source, final long token, final int lineNumber) {
- super(source, token, Token.descPosition(token));
+ public LineNumberNode(final long token, final int lineNumber) {
+ super(token, Token.descPosition(token));
this.lineNumber = lineNumber;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java
index 5d41c9562d6..4c2f932cf4d 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java
@@ -37,7 +37,6 @@ import jdk.nashorn.internal.parser.Token;
import jdk.nashorn.internal.parser.TokenType;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ScriptRuntime;
-import jdk.nashorn.internal.runtime.Source;
import jdk.nashorn.internal.runtime.Undefined;
/**
@@ -50,16 +49,15 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/** Literal value */
protected final T value;
- /**
+ /**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param value the value of the literal
*/
- protected LiteralNode(final Source source, final long token, final int finish, final T value) {
- super(source, token, finish);
+ protected LiteralNode(final long token, final int finish, final T value) {
+ super(token, finish);
this.value = value;
}
@@ -238,14 +236,13 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new null literal
*
- * @param source the source
* @param token token
* @param finish finish
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish) {
- return new NodeLiteralNode(source, token, finish);
+ public static LiteralNode newInstance(final long token, final int finish) {
+ return new NodeLiteralNode(token, finish);
}
/**
@@ -256,14 +253,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent) {
- return new NodeLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish());
+ return new NodeLiteralNode(parent.getToken(), parent.getFinish());
}
@Immutable
private static final class BooleanLiteralNode extends LiteralNode {
- private BooleanLiteralNode(final Source source, final long token, final int finish, final boolean value) {
- super(source, Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value);
+ private BooleanLiteralNode(final long token, final int finish, final boolean value) {
+ super(Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value);
}
private BooleanLiteralNode(final BooleanLiteralNode literalNode) {
@@ -289,15 +286,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new boolean literal
*
- * @param source the source
* @param token token
* @param finish finish
* @param value true or false
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final boolean value) {
- return new BooleanLiteralNode(source, token, finish, value);
+ public static LiteralNode newInstance(final long token, final int finish, final boolean value) {
+ return new BooleanLiteralNode(token, finish, value);
}
/**
@@ -309,7 +305,7 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final boolean value) {
- return new BooleanLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
+ return new BooleanLiteralNode(parent.getToken(), parent.getFinish(), value);
}
@Immutable
@@ -317,8 +313,8 @@ public abstract class LiteralNode extends Node implements PropertyKey {
private final Type type = numberGetType(value);
- private NumberLiteralNode(final Source source, final long token, final int finish, final Number value) {
- super(source, Token.recast(token, TokenType.DECIMAL), finish, value);
+ private NumberLiteralNode(final long token, final int finish, final Number value) {
+ super(Token.recast(token, TokenType.DECIMAL), finish, value);
}
private NumberLiteralNode(final NumberLiteralNode literalNode) {
@@ -353,15 +349,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new number literal
*
- * @param source the source
* @param token token
* @param finish finish
* @param value literal value
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final Number value) {
- return new NumberLiteralNode(source, token, finish, value);
+ public static LiteralNode newInstance(final long token, final int finish, final Number value) {
+ return new NumberLiteralNode(token, finish, value);
}
/**
@@ -373,12 +368,12 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final Number value) {
- return new NumberLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
+ return new NumberLiteralNode(parent.getToken(), parent.getFinish(), value);
}
private static class UndefinedLiteralNode extends LiteralNode {
- private UndefinedLiteralNode(final Source source, final long token, final int finish) {
- super(source, Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED);
+ private UndefinedLiteralNode(final long token, final int finish) {
+ super(Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED);
}
private UndefinedLiteralNode(final UndefinedLiteralNode literalNode) {
@@ -389,15 +384,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new undefined literal
*
- * @param source the source
* @param token token
* @param finish finish
* @param value undefined value, passed only for polymorphisism discrimination
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final Undefined value) {
- return new UndefinedLiteralNode(source, token, finish);
+ public static LiteralNode newInstance(final long token, final int finish, final Undefined value) {
+ return new UndefinedLiteralNode(token, finish);
}
/**
@@ -409,13 +403,13 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final Undefined value) {
- return new UndefinedLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish());
+ return new UndefinedLiteralNode(parent.getToken(), parent.getFinish());
}
@Immutable
private static class StringLiteralNode extends LiteralNode {
- private StringLiteralNode(final Source source, final long token, final int finish, final String value) {
- super(source, Token.recast(token, TokenType.STRING), finish, value);
+ private StringLiteralNode(final long token, final int finish, final String value) {
+ super(Token.recast(token, TokenType.STRING), finish, value);
}
private StringLiteralNode(final StringLiteralNode literalNode) {
@@ -433,15 +427,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new string literal
*
- * @param source the source
* @param token token
* @param finish finish
* @param value string value
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final String value) {
- return new StringLiteralNode(source, token, finish, value);
+ public static LiteralNode newInstance(final long token, final int finish, final String value) {
+ return new StringLiteralNode(token, finish, value);
}
/**
@@ -453,13 +446,13 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final String value) {
- return new StringLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
+ return new StringLiteralNode(parent.getToken(), parent.getFinish(), value);
}
@Immutable
private static class LexerTokenLiteralNode extends LiteralNode {
- private LexerTokenLiteralNode(final Source source, final long token, final int finish, final LexerToken value) {
- super(source, Token.recast(token, TokenType.STRING), finish, value); //TODO is string the correct token type here?
+ private LexerTokenLiteralNode(final long token, final int finish, final LexerToken value) {
+ super(Token.recast(token, TokenType.STRING), finish, value); //TODO is string the correct token type here?
}
private LexerTokenLiteralNode(final LexerTokenLiteralNode literalNode) {
@@ -480,15 +473,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new literal node for a lexer token
*
- * @param source the source
* @param token token
* @param finish finish
* @param value lexer token value
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final LexerToken value) {
- return new LexerTokenLiteralNode(source, token, finish, value);
+ public static LiteralNode newInstance(final long token, final int finish, final LexerToken value) {
+ return new LexerTokenLiteralNode(token, finish, value);
}
/**
@@ -500,17 +492,17 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final LexerToken value) {
- return new LexerTokenLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
+ return new LexerTokenLiteralNode(parent.getToken(), parent.getFinish(), value);
}
private static final class NodeLiteralNode extends LiteralNode {
- private NodeLiteralNode(final Source source, final long token, final int finish) {
- this(source, token, finish, null);
+ private NodeLiteralNode(final long token, final int finish) {
+ this(token, finish, null);
}
- private NodeLiteralNode(final Source source, final long token, final int finish, final Node value) {
- super(source, Token.recast(token, TokenType.OBJECT), finish, value);
+ private NodeLiteralNode(final long token, final int finish, final Node value) {
+ super(Token.recast(token, TokenType.OBJECT), finish, value);
}
private NodeLiteralNode(final LiteralNode literalNode) {
@@ -550,15 +542,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new node literal for an arbitrary node
*
- * @param source the source
* @param token token
* @param finish finish
* @param value the literal value node
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final Node value) {
- return new NodeLiteralNode(source, token, finish, value);
+ public static LiteralNode newInstance(final long token, final int finish, final Node value) {
+ return new NodeLiteralNode(token, finish, value);
}
/**
@@ -570,7 +561,7 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final Node value) {
- return new NodeLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
+ return new NodeLiteralNode(parent.getToken(), parent.getFinish(), value);
}
/**
@@ -645,13 +636,12 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param value array literal value, a Node array
*/
- protected ArrayLiteralNode(final Source source, final long token, final int finish, final Node[] value) {
- super(source, Token.recast(token, TokenType.ARRAY), finish, value);
+ protected ArrayLiteralNode(final long token, final int finish, final Node[] value) {
+ super(Token.recast(token, TokenType.ARRAY), finish, value);
this.elementType = Type.UNKNOWN;
}
@@ -886,15 +876,14 @@ public abstract class LiteralNode extends Node implements PropertyKey {
/**
* Create a new array literal of Nodes from a list of Node values
*
- * @param source the source
* @param token token
* @param finish finish
* @param value literal value list
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final List value) {
- return new ArrayLiteralNode(source, token, finish, value.toArray(new Node[value.size()]));
+ public static LiteralNode newInstance(final long token, final int finish, final List value) {
+ return new ArrayLiteralNode(token, finish, value.toArray(new Node[value.size()]));
}
@@ -907,20 +896,19 @@ public abstract class LiteralNode extends Node implements PropertyKey {
* @return the new literal node
*/
public static LiteralNode> newInstance(final Node parent, final List value) {
- return new ArrayLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value.toArray(new Node[value.size()]));
+ return new ArrayLiteralNode(parent.getToken(), parent.getFinish(), value.toArray(new Node[value.size()]));
}
/**
* Create a new array literal of Nodes
*
- * @param source the source
* @param token token
* @param finish finish
* @param value literal value array
*
* @return the new literal node
*/
- public static LiteralNode newInstance(final Source source, final long token, final int finish, final Node[] value) {
- return new ArrayLiteralNode(source, token, finish, value);
+ public static LiteralNode newInstance(final long token, final int finish, final Node[] value) {
+ return new ArrayLiteralNode(token, finish, value);
}
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/Location.java b/nashorn/src/jdk/nashorn/internal/ir/Location.java
deleted file mode 100644
index cd9edb5bd1d..00000000000
--- a/nashorn/src/jdk/nashorn/internal/ir/Location.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.ir;
-
-import jdk.nashorn.internal.parser.Token;
-import jdk.nashorn.internal.parser.TokenType;
-import jdk.nashorn.internal.runtime.Source;
-
-/**
- * Used to locate an entity back to it's source file.
- */
-public class Location implements Cloneable {
- /** Source of entity. */
- private final Source source;
-
- /** Token descriptor. */
- private final long token;
-
- /**
- * Constructor
- *
- * @param source the source
- * @param token token
- */
- public Location(final Source source, final long token) {
- this.source = source;
- this.token = token;
- }
-
- /**
- * Copy constructor
- *
- * @param location source node
- */
- protected Location(final Location location) {
- this.source = location.source;
- this.token = location.token;
- }
-
- @Override
- protected Object clone() {
- try {
- return super.clone();
- } catch(CloneNotSupportedException e) {
- throw new AssertionError(e);
- }
- }
-
- @Override
- public final boolean equals(final Object other) {
- return super.equals(other);
- }
-
- @Override
- public final int hashCode() {
- return super.hashCode();
- }
-
- /**
- * Return token position from a token descriptor.
- *
- * @return Start position of the token in the source.
- */
- public int position() {
- return Token.descPosition(token);
- }
-
- /**
- * Return token length from a token descriptor.
- *
- * @return Length of the token.
- */
- public int length() {
- return Token.descLength(token);
- }
-
- /**
- * Return token tokenType from a token descriptor.
- *
- * @return Type of token.
- */
- public TokenType tokenType() {
- return Token.descType(token);
- }
-
- /**
- * Test token tokenType.
- *
- * @param type a type to check this token against
- * @return true if token types match.
- */
- public boolean isTokenType(final TokenType type) {
- return Token.descType(token) == type;
- }
-
- /**
- * Get the source for this location
- * @return the source
- */
- public Source getSource() {
- return source;
- }
-
- /**
- * Get the token for this location
- * @return the token
- */
- public long getToken() {
- return token;
- }
-}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/LoopNode.java b/nashorn/src/jdk/nashorn/internal/ir/LoopNode.java
index b3909dc266d..f4bbebe4551 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/LoopNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/LoopNode.java
@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.List;
import jdk.nashorn.internal.codegen.Label;
-import jdk.nashorn.internal.runtime.Source;
/**
* A loop node, for example a while node, do while node or for node
@@ -50,15 +49,14 @@ public abstract class LoopNode extends BreakableNode {
/**
* Constructor
*
- * @param source source
* @param token token
* @param finish finish
* @param test test, or null if infinite loop
* @param body loop body
* @param controlFlowEscapes controlFlowEscapes
*/
- protected LoopNode(final Source source, final long token, final int finish, final Node test, final Block body, final boolean controlFlowEscapes) {
- super(source, token, finish, new Label("while_break"));
+ protected LoopNode(final long token, final int finish, final Node test, final Block body, final boolean controlFlowEscapes) {
+ super(token, finish, new Label("while_break"));
this.continueLabel = new Label("while_continue");
this.test = test;
this.body = body;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/Node.java b/nashorn/src/jdk/nashorn/internal/ir/Node.java
index d370f22f12f..a86c57f4daf 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/Node.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/Node.java
@@ -31,12 +31,12 @@ import java.util.List;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.parser.Token;
-import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.parser.TokenType;
/**
* Nodes are used to compose Abstract Syntax Trees.
*/
-public abstract class Node extends Location {
+public abstract class Node implements Cloneable {
/** Node symbol. */
private Symbol symbol;
@@ -46,16 +46,17 @@ public abstract class Node extends Location {
/** End of source range. */
protected int finish;
+ /** Token descriptor. */
+ private final long token;
+
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
*/
- public Node(final Source source, final long token, final int finish) {
- super(source, token);
-
+ public Node(final long token, final int finish) {
+ this.token = token;
this.start = Token.descPosition(token);
this.finish = finish;
}
@@ -63,16 +64,14 @@ public abstract class Node extends Location {
/**
* Constructor
*
- * @param source source
* @param token token
* @param start start
* @param finish finish
*/
- protected Node(final Source source, final long token, final int start, final int finish) {
- super(source, token);
-
+ protected Node(final long token, final int start, final int finish) {
this.start = start;
this.finish = finish;
+ this.token = token;
}
/**
@@ -81,8 +80,7 @@ public abstract class Node extends Location {
* @param node source node
*/
protected Node(final Node node) {
- super(node);
-
+ this.token = node.token;
this.symbol = node.symbol;
this.start = node.start;
this.finish = node.finish;
@@ -248,6 +246,15 @@ public abstract class Node extends Location {
return symbol;
}
+ @Override
+ protected Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException e) {
+ throw new AssertionError(e);
+ }
+ }
+
/**
* Assign a symbol to this node. See {@link Node#getSymbol()} for explanation
* of what a symbol is
@@ -265,6 +272,62 @@ public abstract class Node extends Location {
return newNode;
}
+
+ @Override
+ public final boolean equals(final Object other) {
+ return super.equals(other);
+ }
+
+ @Override
+ public final int hashCode() {
+ return super.hashCode();
+ }
+
+ /**
+ * Return token position from a token descriptor.
+ *
+ * @return Start position of the token in the source.
+ */
+ public int position() {
+ return Token.descPosition(token);
+ }
+
+ /**
+ * Return token length from a token descriptor.
+ *
+ * @return Length of the token.
+ */
+ public int length() {
+ return Token.descLength(token);
+ }
+
+ /**
+ * Return token tokenType from a token descriptor.
+ *
+ * @return Type of token.
+ */
+ public TokenType tokenType() {
+ return Token.descType(token);
+ }
+
+ /**
+ * Test token tokenType.
+ *
+ * @param type a type to check this token against
+ * @return true if token types match.
+ */
+ public boolean isTokenType(final TokenType type) {
+ return Token.descType(token) == type;
+ }
+
+ /**
+ * Get the token for this location
+ * @return the token
+ */
+ public long getToken() {
+ return token;
+ }
+
/**
* Is this a terminal Node, i.e. does it end control flow like a throw or return
* expression does?
diff --git a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java
index 744a44d7a56..34069725640 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java
@@ -30,7 +30,6 @@ import java.util.List;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of an object literal.
@@ -44,13 +43,12 @@ public final class ObjectNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param elements the elements used to initialize this ObjectNode
*/
- public ObjectNode(final Source source, final long token, final int finish, final List elements) {
- super(source, token, finish);
+ public ObjectNode(final long token, final int finish, final List elements) {
+ super(token, finish);
this.elements = elements;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java b/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java
index 635e1aa3889..7040d41477d 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of an object literal property.
@@ -50,7 +49,6 @@ public final class PropertyNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param key the key of this property
@@ -58,8 +56,8 @@ public final class PropertyNode extends Node {
* @param getter getter function body
* @param setter setter function body
*/
- public PropertyNode(final Source source, final long token, final int finish, final PropertyKey key, final Node value, final FunctionNode getter, final FunctionNode setter) {
- super(source, token, finish);
+ public PropertyNode(final long token, final int finish, final PropertyKey key, final Node value, final FunctionNode getter, final FunctionNode setter) {
+ super(token, finish);
this.key = key;
this.value = value;
this.getter = getter;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java b/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java
index dafc956deec..cb736e427ed 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java
@@ -29,7 +29,6 @@ import static jdk.nashorn.internal.parser.TokenType.RETURN;
import static jdk.nashorn.internal.parser.TokenType.YIELD;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for RETURN or YIELD statements.
@@ -42,13 +41,12 @@ public class ReturnNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param expression expression to return
*/
- public ReturnNode(final Source source, final long token, final int finish, final Node expression) {
- super(source, token, finish);
+ public ReturnNode(final long token, final int finish, final Node expression) {
+ super(token, finish);
this.expression = expression;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java
index 7bdb6c0adb8..ceef9b9b823 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java
@@ -33,7 +33,6 @@ import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.parser.TokenType;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for a runtime call.
@@ -280,14 +279,13 @@ public class RuntimeNode extends Node implements TypeOverride {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param request the request
* @param args arguments to request
*/
- public RuntimeNode(final Source source, final long token, final int finish, final Request request, final List args) {
- super(source, token, finish);
+ public RuntimeNode(final long token, final int finish, final Request request, final List args) {
+ super(token, finish);
this.request = request;
this.args = args;
@@ -307,14 +305,13 @@ public class RuntimeNode extends Node implements TypeOverride {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param request the request
* @param args arguments to request
*/
- public RuntimeNode(final Source source, final long token, final int finish, final Request request, final Node... args) {
- this(source, token, finish, request, Arrays.asList(args));
+ public RuntimeNode(final long token, final int finish, final Request request, final Node... args) {
+ this(token, finish, request, Arrays.asList(args));
}
/**
diff --git a/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java b/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java
index 49c4092f221..05b2b04b20d 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java
@@ -51,7 +51,7 @@ public class SplitNode extends LexicalContextNode {
* @param compileUnit compile unit to use for the body
*/
public SplitNode(final String name, final Node body, final CompileUnit compileUnit) {
- super(body.getSource(), body.getToken(), body.getFinish());
+ super(body.getToken(), body.getFinish());
this.name = name;
this.body = body;
this.compileUnit = compileUnit;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java
index 7864a10d0a8..640911148c6 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java
@@ -32,7 +32,6 @@ import java.util.List;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of a SWITCH statement.
@@ -54,15 +53,14 @@ public final class SwitchNode extends BreakableNode {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param expression switch expression
* @param cases cases
* @param defaultCase the default case node - null if none, otherwise has to be present in cases list
*/
- public SwitchNode(final Source source, final long token, final int finish, final Node expression, final List cases, final CaseNode defaultCase) {
- super(source, token, finish, new Label("switch_break"));
+ public SwitchNode(final long token, final int finish, final Node expression, final List cases, final CaseNode defaultCase) {
+ super(token, finish, new Label("switch_break"));
this.expression = expression;
this.cases = cases;
this.defaultCaseIndex = defaultCase == null ? -1 : cases.indexOf(defaultCase);
diff --git a/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java
index e2ccdb91173..25ac1a4ddaa 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* TernaryNode nodes represent three operand operations (?:).
@@ -44,14 +43,13 @@ public final class TernaryNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param lhs left hand side node
* @param rhs right hand side node
* @param third third node
*/
- public TernaryNode(final Source source, final long token, final Node lhs, final Node rhs, final Node third) {
- super(source, token, third.getFinish());
+ public TernaryNode(final long token, final Node lhs, final Node rhs, final Node third) {
+ super(token, third.getFinish());
this.lhs = lhs;
this.rhs = rhs;
this.third = third;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java
index 7a10a6add83..d7e6575b160 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for THROW statements.
@@ -40,14 +39,12 @@ public final class ThrowNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param expression expression to throw
*/
- public ThrowNode(final Source source, final long token, final int finish, final Node expression) {
- super(source, token, finish);
-
+ public ThrowNode(final long token, final int finish, final Node expression) {
+ super(token, finish);
this.expression = expression;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java
index 5e3ff7af135..0cca5ea86b0 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java
@@ -32,7 +32,6 @@ import java.util.List;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation of a TRY statement.
@@ -60,15 +59,14 @@ public final class TryNode extends Node {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param body try node body
* @param catchBlocks list of catch blocks in order
* @param finallyBody body of finally block or null if none
*/
- public TryNode(final Source source, final long token, final int finish, final Block body, final List catchBlocks, final Block finallyBody) {
- super(source, token, finish);
+ public TryNode(final long token, final int finish, final Block body, final List catchBlocks, final Block finallyBody) {
+ super(token, finish);
this.body = body;
this.catchBlocks = catchBlocks;
this.finallyBody = finallyBody;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java
index fed5e408293..ed1d8a9bdbe 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java
@@ -35,7 +35,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.parser.Token;
import jdk.nashorn.internal.parser.TokenType;
-import jdk.nashorn.internal.runtime.Source;
/**
* UnaryNode nodes represent single operand operations.
@@ -48,24 +47,23 @@ public final class UnaryNode extends Node implements Assignment {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param rhs expression
*/
- public UnaryNode(final Source source, final long token, final Node rhs) {
- this(source, token, Math.min(rhs.getStart(), Token.descPosition(token)), Math.max(Token.descPosition(token) + Token.descLength(token), rhs.getFinish()), rhs);
+ public UnaryNode(final long token, final Node rhs) {
+ this(token, Math.min(rhs.getStart(), Token.descPosition(token)), Math.max(Token.descPosition(token) + Token.descLength(token), rhs.getFinish()), rhs);
}
/**
* Constructor
- * @param source the source
+ *
* @param token token
* @param start start
* @param finish finish
* @param rhs expression
*/
- public UnaryNode(final Source source, final long token, final int start, final int finish, final Node rhs) {
- super(source, token, start, finish);
+ public UnaryNode(final long token, final int start, final int finish, final Node rhs) {
+ super(token, start, finish);
this.rhs = rhs;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/VarNode.java b/nashorn/src/jdk/nashorn/internal/ir/VarNode.java
index fbc3eabecd2..ae3518a767f 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/VarNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/VarNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* Node represents a var/let declaration.
@@ -54,14 +53,13 @@ public final class VarNode extends Node implements Assignment {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param name name of variable
* @param init init node or null if just a declaration
*/
- public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init) {
- this(source, token, finish, name, init, IS_STATEMENT);
+ public VarNode(final long token, final int finish, final IdentNode name, final Node init) {
+ this(token, finish, name, init, IS_STATEMENT);
}
private VarNode(final VarNode varNode, final IdentNode name, final Node init, final int flags) {
@@ -74,15 +72,14 @@ public final class VarNode extends Node implements Assignment {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param name name of variable
* @param init init node or null if just a declaration
* @param flags flags
*/
- public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init, final int flags) {
- super(source, token, finish);
+ public VarNode(final long token, final int finish, final IdentNode name, final Node init, final int flags) {
+ super(token, finish);
this.name = init == null ? name : name.setIsInitializedHere();
this.init = init;
diff --git a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java
index 438be0131e6..fd347947b41 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for a WHILE statement. This is the superclass of all
@@ -42,13 +41,12 @@ public final class WhileNode extends LoopNode {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
* @param isDoWhile is this a do while loop?
*/
- public WhileNode(final Source source, final long token, final int finish, final boolean isDoWhile) {
- super(source, token, finish, null, null, false);
+ public WhileNode(final long token, final int finish, final boolean isDoWhile) {
+ super(token, finish, null, null, false);
this.isDoWhile = isDoWhile;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/WithNode.java b/nashorn/src/jdk/nashorn/internal/ir/WithNode.java
index 5ebbfd55d6d..64d735b5eec 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/WithNode.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/WithNode.java
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
-import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for {@code with} statements.
@@ -43,20 +42,17 @@ public final class WithNode extends LexicalContextNode {
/**
* Constructor
*
- * @param source the source
* @param token token
* @param finish finish
*/
- public WithNode(final Source source, final long token, final int finish) {
- super(source, token, finish);
-
+ public WithNode(final long token, final int finish) {
+ super(token, finish);
this.expression = null;
this.body = null;
}
private WithNode(final WithNode node, final Node expression, final Block body) {
super(node);
-
this.expression = expression;
this.body = body;
}
diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java
index 988b756c9fd..24273ac1304 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java
@@ -971,7 +971,7 @@ public final class JSONWriter extends NodeVisitor {
objectStart("loc");
// source name
- final Source src = node.getSource();
+ final Source src = getLexicalContext().getCurrentFunction().getSource();
property("source", src.getName());
comma();
diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
index 337f2e3d5b1..bcc9b5c2318 100644
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
@@ -178,7 +178,6 @@ public final class NativeDebug extends ScriptObject {
* @param self self reference
* @return undefined
*/
- @SuppressWarnings("resource")
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object dumpCounters(final Object self) {
final PrintWriter out = Context.getCurrentErr();
diff --git a/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java b/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java
index b87d9cf3fea..25b500cef07 100644
--- a/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java
+++ b/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java
@@ -364,7 +364,7 @@ public abstract class AbstractParser {
next();
// Create IDENT node.
- return new IdentNode(source, identToken, finish, ident);
+ return new IdentNode(identToken, finish, ident);
}
// Get IDENT.
@@ -373,7 +373,7 @@ public abstract class AbstractParser {
return null;
}
// Create IDENT node.
- return new IdentNode(source, identToken, finish, ident);
+ return new IdentNode(identToken, finish, ident);
}
/**
@@ -408,7 +408,7 @@ public abstract class AbstractParser {
final String ident = (String)getValue(identToken);
next();
// Create IDENT node.
- return new IdentNode(source, identToken, finish, ident);
+ return new IdentNode(identToken, finish, ident);
} else {
expect(IDENT);
return null;
@@ -433,11 +433,11 @@ public abstract class AbstractParser {
LiteralNode> node = null;
if (value == null) {
- node = LiteralNode.newInstance(source, literalToken, finish);
+ node = LiteralNode.newInstance(literalToken, finish);
} else if (value instanceof Number) {
- node = LiteralNode.newInstance(source, literalToken, finish, (Number)value);
+ node = LiteralNode.newInstance(literalToken, finish, (Number)value);
} else if (value instanceof String) {
- node = LiteralNode.newInstance(source, literalToken, finish, (String)value);
+ node = LiteralNode.newInstance(literalToken, finish, (String)value);
} else if (value instanceof LexerToken) {
if (value instanceof RegexToken) {
final RegexToken regex = (RegexToken)value;
@@ -447,7 +447,7 @@ public abstract class AbstractParser {
throw error(e.getMessage());
}
}
- node = LiteralNode.newInstance(source, literalToken, finish, (LexerToken)value);
+ node = LiteralNode.newInstance(literalToken, finish, (LexerToken)value);
} else {
assert false : "unknown type for LiteralNode: " + value.getClass();
}
diff --git a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java
index e074cf01a1c..d4985ea337e 100644
--- a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java
+++ b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java
@@ -193,13 +193,13 @@ public class JSONParser extends AbstractParser {
return getLiteral();
case FALSE:
next();
- return LiteralNode.newInstance(source, literalToken, finish, false);
+ return LiteralNode.newInstance(literalToken, finish, false);
case TRUE:
next();
- return LiteralNode.newInstance(source, literalToken, finish, true);
+ return LiteralNode.newInstance(literalToken, finish, true);
case NULL:
next();
- return LiteralNode.newInstance(source, literalToken, finish);
+ return LiteralNode.newInstance(literalToken, finish);
case LBRACKET:
return arrayLiteral();
case LBRACE:
@@ -218,7 +218,7 @@ public class JSONParser extends AbstractParser {
if (value instanceof Number) {
next();
- return new UnaryNode(source, literalToken, LiteralNode.newInstance(source, realToken, finish, (Number)value));
+ return new UnaryNode(literalToken, LiteralNode.newInstance(realToken, finish, (Number)value));
}
throw error(AbstractParser.message("expected", "number", type.getNameOrType()));
@@ -250,7 +250,7 @@ loop:
switch (type) {
case RBRACKET:
next();
- result = LiteralNode.newInstance(source, arrayToken, finish, elements);
+ result = LiteralNode.newInstance(arrayToken, finish, elements);
break loop;
case COMMARIGHT:
@@ -310,7 +310,7 @@ loop:
}
// Construct new object literal.
- return new ObjectNode(source, objectToken, finish, elements);
+ return new ObjectNode(objectToken, finish, elements);
}
/**
@@ -331,7 +331,7 @@ loop:
if (name != null) {
expect(COLON);
final Node value = jsonLiteral();
- return new PropertyNode(source, propertyToken, value.getFinish(), name, value, null, null);
+ return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
}
// Raise an error.
diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java
index 6302d1f7b03..05807bab2e5 100644
--- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java
+++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java
@@ -275,8 +275,7 @@ loop:
* @return New block.
*/
private Block newBlock() {
- final Block block = new Block(source, token, Token.descPosition(token));
- return lc.push(block);
+ return lc.push(new Block(token, Token.descPosition(token)));
}
/**
@@ -479,7 +478,7 @@ loop:
}
// Build up node.
- return new BinaryNode(source, op, lhs, rhs);
+ return new BinaryNode(op, lhs, rhs);
}
/**
@@ -490,12 +489,12 @@ loop:
* @param isPostfix Prefix or postfix.
* @return Reduced expression.
*/
- private Node incDecExpression(final long firstToken, final TokenType tokenType, final Node expression, final boolean isPostfix) {
+ private static Node incDecExpression(final long firstToken, final TokenType tokenType, final Node expression, final boolean isPostfix) {
if (isPostfix) {
- return new UnaryNode(source, Token.recast(firstToken, tokenType == DECPREFIX ? DECPOSTFIX : INCPOSTFIX), expression.getStart(), Token.descPosition(firstToken) + Token.descLength(firstToken), expression);
+ return new UnaryNode(Token.recast(firstToken, tokenType == DECPREFIX ? DECPOSTFIX : INCPOSTFIX), expression.getStart(), Token.descPosition(firstToken) + Token.descLength(firstToken), expression);
}
- return new UnaryNode(source, firstToken, expression);
+ return new UnaryNode(firstToken, expression);
}
/**
@@ -524,7 +523,7 @@ loop:
FunctionNode script = newFunctionNode(
functionToken,
- new IdentNode(source, functionToken, Token.descPosition(functionToken), scriptName),
+ new IdentNode(functionToken, Token.descPosition(functionToken), scriptName),
new ArrayList(),
FunctionNode.Kind.SCRIPT);
@@ -774,7 +773,7 @@ loop:
private void block() {
final Block newBlock = getBlock(true);
// Force block execution.
- appendStatement(new ExecuteNode(source, newBlock.getToken(), finish, newBlock));
+ appendStatement(new ExecuteNode(newBlock.getToken(), finish, newBlock));
}
/**
@@ -867,7 +866,7 @@ loop:
}
// Allocate var node.
- final VarNode var = new VarNode(source, varToken, finish, name, init);
+ final VarNode var = new VarNode(varToken, finish, name, init);
vars.add(var);
appendStatement(var);
@@ -899,7 +898,7 @@ loop:
*/
private void emptyStatement() {
if (env._empty_statements) {
- appendStatement(new EmptyNode(source, token, Token.descPosition(token) + Token.descLength(token)));
+ appendStatement(new EmptyNode(token, Token.descPosition(token) + Token.descLength(token)));
}
// SEMICOLON checked in caller.
@@ -923,7 +922,7 @@ loop:
ExecuteNode executeNode = null;
if (expression != null) {
- executeNode = new ExecuteNode(source, expressionToken, finish, expression);
+ executeNode = new ExecuteNode(expressionToken, finish, expression);
appendStatement(executeNode);
} else {
expect(null);
@@ -963,7 +962,7 @@ loop:
fail = getStatement();
}
- appendStatement(new IfNode(source, ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail));
+ appendStatement(new IfNode(ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail));
}
/**
@@ -980,7 +979,7 @@ loop:
*/
private void forStatement() {
// Create FOR node, capturing FOR token.
- ForNode forNode = new ForNode(source, token, Token.descPosition(token), null, null, null, null, ForNode.IS_FOR);
+ ForNode forNode = new ForNode(token, Token.descPosition(token), null, null, null, null, ForNode.IS_FOR);
// Set up new block for scope of vars. Captures first token.
@@ -1084,7 +1083,7 @@ loop:
outer = restoreBlock(outer);
}
- appendStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer));
+ appendStatement(new ExecuteNode(outer.getToken(), outer.getFinish(), outer));
}
/**
@@ -1120,7 +1119,7 @@ loop:
next();
// Construct WHILE node.
- WhileNode whileNode = new WhileNode(source, whileToken, Token.descPosition(whileToken), false);
+ WhileNode whileNode = new WhileNode(whileToken, Token.descPosition(whileToken), false);
lc.push(whileNode);
try {
@@ -1150,7 +1149,7 @@ loop:
// DO tested in the caller.
next();
- WhileNode doWhileNode = new WhileNode(source, doToken, Token.descPosition(doToken), true);
+ WhileNode doWhileNode = new WhileNode(doToken, Token.descPosition(doToken), true);
lc.push(doWhileNode);
try {
@@ -1216,7 +1215,7 @@ loop:
endOfLine();
// Construct and add CONTINUE node.
- appendStatement(new ContinueNode(source, continueToken, finish, label == null ? null : new IdentNode(label)));
+ appendStatement(new ContinueNode(continueToken, finish, label == null ? null : new IdentNode(label)));
}
/**
@@ -1263,7 +1262,7 @@ loop:
endOfLine();
// Construct and add BREAK node.
- appendStatement(new BreakNode(source, breakToken, finish, label == null ? null : new IdentNode(label)));
+ appendStatement(new BreakNode(breakToken, finish, label == null ? null : new IdentNode(label)));
}
/**
@@ -1302,7 +1301,7 @@ loop:
endOfLine();
// Construct and add RETURN node.
- appendStatement(new ReturnNode(source, returnToken, finish, expression));
+ appendStatement(new ReturnNode(returnToken, finish, expression));
}
/**
@@ -1336,7 +1335,7 @@ loop:
endOfLine();
// Construct and add YIELD node.
- appendStatement(new ReturnNode(source, yieldToken, finish, expression));
+ appendStatement(new ReturnNode(yieldToken, finish, expression));
}
/**
@@ -1359,7 +1358,7 @@ loop:
}
// Get WITH expression.
- WithNode withNode = new WithNode(source, withToken, finish);
+ WithNode withNode = new WithNode(withToken, finish);
try {
lc.push(withNode);
@@ -1402,7 +1401,7 @@ loop:
next();
// Create and add switch statement.
- SwitchNode switchNode = new SwitchNode(source, switchToken, Token.descPosition(switchToken), null, new ArrayList(), null);
+ SwitchNode switchNode = new SwitchNode(switchToken, Token.descPosition(switchToken), null, new ArrayList(), null);
lc.push(switchNode);
try {
@@ -1444,7 +1443,7 @@ loop:
// Get CASE body.
final Block statements = getBlock(false);
- final CaseNode caseNode = new CaseNode(source, caseToken, finish, caseExpression, statements);
+ final CaseNode caseNode = new CaseNode(caseToken, finish, caseExpression, statements);
statements.setFinish(finish);
if (caseExpression == null) {
@@ -1484,7 +1483,7 @@ loop:
throw error(AbstractParser.message("duplicate.label", ident.getName()), labelToken);
}
- LabelNode labelNode = new LabelNode(source, labelToken, finish, ident, null);
+ LabelNode labelNode = new LabelNode(labelToken, finish, ident, null);
try {
lc.push(labelNode);
labelNode = labelNode.setBody(lc, getStatement());
@@ -1530,7 +1529,7 @@ loop:
endOfLine();
- appendStatement(new ThrowNode(source, throwToken, finish, expression));
+ appendStatement(new ThrowNode(throwToken, finish, expression));
}
/**
@@ -1588,7 +1587,7 @@ loop:
try {
// Get CATCH body.
final Block catchBody = getBlock(true);
- final CatchNode catchNode = new CatchNode(source, catchToken, finish, exception, ifExpression, catchBody);
+ final CatchNode catchNode = new CatchNode(catchToken, finish, exception, ifExpression, catchBody);
appendStatement(catchNode);
} finally {
catchBlock = restoreBlock(catchBlock);
@@ -1614,7 +1613,7 @@ loop:
throw error(AbstractParser.message("missing.catch.or.finally"), tryToken);
}
- final TryNode tryNode = new TryNode(source, tryToken, Token.descPosition(tryToken), tryBody, catchBlocks, finallyStatements);
+ final TryNode tryNode = new TryNode(tryToken, Token.descPosition(tryToken), tryBody, catchBlocks, finallyStatements);
// Add try.
assert lc.peek() == outer;
appendStatement(tryNode);
@@ -1626,7 +1625,7 @@ loop:
outer = restoreBlock(outer);
}
- appendStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer));
+ appendStatement(new ExecuteNode(outer.getToken(), outer.getFinish(), outer));
}
/**
@@ -1643,7 +1642,7 @@ loop:
// DEBUGGER tested in caller.
next();
endOfLine();
- appendStatement(new RuntimeNode(source, debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList()));
+ appendStatement(new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList()));
}
/**
@@ -1669,7 +1668,7 @@ loop:
case THIS:
final String name = type.getName();
next();
- return new IdentNode(source, primaryToken, finish, name);
+ return new IdentNode(primaryToken, finish, name);
case IDENT:
final IdentNode ident = getIdent();
if (ident == null) {
@@ -1693,13 +1692,13 @@ loop:
return execString(primaryToken);
case FALSE:
next();
- return LiteralNode.newInstance(source, primaryToken, finish, false);
+ return LiteralNode.newInstance(primaryToken, finish, false);
case TRUE:
next();
- return LiteralNode.newInstance(source, primaryToken, finish, true);
+ return LiteralNode.newInstance(primaryToken, finish, true);
case NULL:
next();
- return LiteralNode.newInstance(source, primaryToken, finish);
+ return LiteralNode.newInstance(primaryToken, finish);
case LBRACKET:
return arrayLiteral();
case LBRACE:
@@ -1736,7 +1735,7 @@ loop:
*/
Node execString(final long primaryToken) {
// Synthesize an ident to call $EXEC.
- final IdentNode execIdent = new IdentNode(source, primaryToken, finish, ScriptingFunctions.EXEC_NAME);
+ final IdentNode execIdent = new IdentNode(primaryToken, finish, ScriptingFunctions.EXEC_NAME);
// Skip over EXECSTRING.
next();
// Set up argument list for call.
@@ -1748,7 +1747,7 @@ loop:
// Skip ending of edit string expression.
expect(RBRACE);
- return new CallNode(source, primaryToken, finish, execIdent, arguments);
+ return new CallNode(primaryToken, finish, execIdent, arguments);
}
/**
@@ -1819,7 +1818,7 @@ loop:
}
}
- return LiteralNode.newInstance(source, arrayToken, finish, elements);
+ return LiteralNode.newInstance(arrayToken, finish, elements);
}
/**
@@ -1926,7 +1925,7 @@ loop:
map.put(key, newProperty = newProperty.setValue(value));
} else {
final long propertyToken = Token.recast(newProperty.getToken(), COMMARIGHT);
- map.put(key, newProperty = newProperty.setValue(new BinaryNode(source, propertyToken, prevValue, value)));
+ map.put(key, newProperty = newProperty.setValue(new BinaryNode(propertyToken, prevValue, value)));
}
map.put(key, newProperty = newProperty.setGetter(null).setSetter(null));
@@ -1943,7 +1942,7 @@ loop:
}
}
- return new ObjectNode(source, objectToken, finish, new ArrayList(map.values()));
+ return new ObjectNode(objectToken, finish, new ArrayList(map.values()));
}
/**
@@ -2013,16 +2012,16 @@ loop:
case "get":
final PropertyKey getIdent = propertyName();
final String getterName = getIdent.getPropertyName();
- final IdentNode getNameNode = new IdentNode(source, ((Node)getIdent).getToken(), finish, "get " + getterName);
+ final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName);
expect(LPAREN);
expect(RPAREN);
functionNode = functionBody(getSetToken, getNameNode, new ArrayList(), FunctionNode.Kind.GETTER);
- return new PropertyNode(source, propertyToken, finish, getIdent, null, functionNode, null);
+ return new PropertyNode(propertyToken, finish, getIdent, null, functionNode, null);
case "set":
final PropertyKey setIdent = propertyName();
final String setterName = setIdent.getPropertyName();
- final IdentNode setNameNode = new IdentNode(source, ((Node)setIdent).getToken(), finish, "set " + setterName);
+ final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName);
expect(LPAREN);
final IdentNode argIdent = getIdent();
verifyStrictIdent(argIdent, "setter argument");
@@ -2030,21 +2029,21 @@ loop:
List parameters = new ArrayList<>();
parameters.add(argIdent);
functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER);
- return new PropertyNode(source, propertyToken, finish, setIdent, null, null, functionNode);
+ return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode);
default:
break;
}
}
- propertyName = new IdentNode(source, propertyToken, finish, ident);
+ propertyName = new IdentNode(propertyToken, finish, ident);
} else {
propertyName = propertyName();
}
expect(COLON);
- return new PropertyNode(source, propertyToken, finish, propertyName, assignmentExpression(false), null, null);
+ return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null);
}
/**
@@ -2076,7 +2075,7 @@ loop:
detectSpecialFunction((IdentNode)lhs);
}
- lhs = new CallNode(source, callToken, finish, lhs, arguments);
+ lhs = new CallNode(callToken, finish, lhs, arguments);
}
loop:
@@ -2090,7 +2089,7 @@ loop:
final List arguments = argumentList();
// Create call node.
- lhs = new CallNode(source, callToken, finish, lhs, arguments);
+ lhs = new CallNode(callToken, finish, lhs, arguments);
break;
@@ -2103,7 +2102,7 @@ loop:
expect(RBRACKET);
// Create indexing node.
- lhs = new IndexNode(source, callToken, finish, lhs, rhs);
+ lhs = new IndexNode(callToken, finish, lhs, rhs);
break;
@@ -2113,7 +2112,7 @@ loop:
final IdentNode property = getIdentifierName();
// Create property access node.
- lhs = new AccessNode(source, callToken, finish, lhs, property);
+ lhs = new AccessNode(callToken, finish, lhs, property);
break;
@@ -2169,9 +2168,9 @@ loop:
arguments.add(objectLiteral());
}
- final CallNode callNode = new CallNode(source, constructor.getToken(), finish, constructor, arguments);
+ final CallNode callNode = new CallNode(constructor.getToken(), finish, constructor, arguments);
- return new UnaryNode(source, newToken, callNode);
+ return new UnaryNode(newToken, callNode);
}
/**
@@ -2223,7 +2222,7 @@ loop:
expect(RBRACKET);
// Create indexing node.
- lhs = new IndexNode(source, callToken, finish, lhs, index);
+ lhs = new IndexNode(callToken, finish, lhs, index);
break;
@@ -2237,7 +2236,7 @@ loop:
final IdentNode property = getIdentifierName();
// Create property access node.
- lhs = new AccessNode(source, callToken, finish, lhs, property);
+ lhs = new AccessNode(callToken, finish, lhs, property);
break;
@@ -2326,7 +2325,7 @@ loop:
boolean isAnonymous = false;
if (name == null) {
final String tmpName = "_L" + source.getLine(Token.descPosition(token));
- name = new IdentNode(source, functionToken, Token.descPosition(functionToken), tmpName);
+ name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName);
isAnonymous = true;
}
@@ -2377,7 +2376,7 @@ loop:
// rename in non-strict mode
parameterName = functionNode.uniqueName(parameterName);
final long parameterToken = parameter.getToken();
- parameters.set(i, new IdentNode(source, parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName)));
+ parameters.set(i, new IdentNode(parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName)));
}
parametersSet.add(parameterName);
@@ -2389,7 +2388,7 @@ loop:
}
if (isStatement) {
- final VarNode varNode = new VarNode(source, functionToken, finish, name, functionNode, VarNode.IS_STATEMENT);
+ final VarNode varNode = new VarNode(functionToken, finish, name, functionNode, VarNode.IS_STATEMENT);
if (topLevel) {
functionDeclarations.add(lineNumber);
functionDeclarations.add(varNode);
@@ -2469,7 +2468,7 @@ loop:
assert lc.getCurrentBlock() == lc.getFunctionBody(functionNode);
// create a return statement - this creates code in itself and does not need to be
// wrapped into an ExecuteNode
- final ReturnNode returnNode = new ReturnNode(source, expr.getToken(), finish, expr);
+ final ReturnNode returnNode = new ReturnNode(expr.getToken(), finish, expr);
appendStatement(returnNode);
lastToken = token;
functionNode.setFinish(Token.descPosition(token) + Token.descLength(token));
@@ -2511,16 +2510,16 @@ loop:
}
}
- private RuntimeNode referenceError(final Node lhs, final Node rhs) {
+ private static RuntimeNode referenceError(final Node lhs, final Node rhs) {
final ArrayList args = new ArrayList<>();
args.add(lhs);
if (rhs == null) {
- args.add(LiteralNode.newInstance(source, lhs.getToken(), lhs.getFinish()));
+ args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
} else {
args.add(rhs);
}
- args.add(LiteralNode.newInstance(source, lhs.getToken(), lhs.getFinish(), lhs.toString()));
- return new RuntimeNode(source, lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
+ args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
+ return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
/*
@@ -2570,7 +2569,7 @@ loop:
case NOT:
next();
final Node expr = unaryExpression();
- return new UnaryNode(source, unaryToken, expr);
+ return new UnaryNode(unaryToken, expr);
case INCPREFIX:
case DECPREFIX:
@@ -2759,7 +2758,7 @@ loop:
final Node third = expression(unaryExpression(), ASSIGN.getPrecedence(), noIn);
// Build up node.
- lhs = new TernaryNode(source, op, lhs, rhs, third);
+ lhs = new TernaryNode(op, lhs, rhs, third);
} else {
// Skip operator.
next();
@@ -2820,7 +2819,7 @@ loop:
*/
private LineNumberNode lineNumber() {
if (env._debug_lines) {
- return new LineNumberNode(source, token, line);
+ return new LineNumberNode(token, line);
}
return null;
}
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
index 1ba74f13db8..03a25dab1b7 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
@@ -229,6 +229,10 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData {
}
final FunctionNode snapshot = functionNode.getSnapshot();
+ if (snapshot == null) {
+ return mh;
+ }
+
int i;
//classes known at runtime
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
index 01d61d7f510..61cce7b127a 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
@@ -970,9 +970,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
* @param bindName null or name to bind to second argument (property not found method.)
*
* @return value of property as a MethodHandle or null.
- *
*/
- @SuppressWarnings("static-method")
protected MethodHandle getCallMethodHandle(final FindProperty find, final MethodType type, final String bindName) {
return getCallMethodHandle(getObjectValue(find), type, bindName);
}
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
index 1703b7ecf14..5061683a355 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
@@ -57,7 +57,6 @@ abstract public class ArrayLikeIterator implements Iterator {
* Is this a reverse order iteration?
* @return true if reverse
*/
- @SuppressWarnings("static-method")
public boolean isReverse() {
return false;
}
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
index 05b1a9396ef..ce71caada9d 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
@@ -275,7 +275,6 @@ public class LinkerCallSite extends ChainedCallSite {
}
static class ProfileDumper implements Runnable {
- @SuppressWarnings("resource")
@Override
public void run() {
PrintWriter out = null;
@@ -447,7 +446,7 @@ public class LinkerCallSite extends ChainedCallSite {
*
* @throws Throwable if invocation fails or throws exception/error
*/
- @SuppressWarnings({"unused", "resource"})
+ @SuppressWarnings("unused")
public Object traceObject(final MethodHandle mh, final Object... args) throws Throwable {
final PrintWriter out = Context.getCurrentErr();
tracePrint(out, "ENTER ", args, null);
@@ -465,7 +464,7 @@ public class LinkerCallSite extends ChainedCallSite {
*
* @throws Throwable if invocation fails or throws exception/error
*/
- @SuppressWarnings({"unused", "resource"})
+ @SuppressWarnings("unused")
public void traceVoid(final MethodHandle mh, final Object... args) throws Throwable {
final PrintWriter out = Context.getCurrentErr();
tracePrint(out, "ENTER ", args, null);
diff --git a/nashorn/src/jdk/nashorn/tools/Shell.java b/nashorn/src/jdk/nashorn/tools/Shell.java
index 708fecc59f1..ddc520e6b70 100644
--- a/nashorn/src/jdk/nashorn/tools/Shell.java
+++ b/nashorn/src/jdk/nashorn/tools/Shell.java
@@ -392,7 +392,6 @@ public class Shell {
* @param global global scope object to use
* @return return code
*/
- @SuppressWarnings("resource")
private static int readEvalPrint(final Context context, final ScriptObject global) {
final String prompt = bundle.getString("shell.prompt");
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
From c668214703db7f1abe8501e401abd1c20893fcc1 Mon Sep 17 00:00:00 2001
From: Marcus Lagergren
Date: Tue, 7 May 2013 14:43:17 +0200
Subject: [PATCH 022/147] 8013914: Removed explicit LineNumberNodes that were
too brittle when code moves around, and also introduced unnecessary
footprint. Introduced the Statement node and fixed dead code elimination
issues that were discovered by the absense of labels for LineNumberNodes
Reviewed-by: jlaskey, attila
---
nashorn/make/project.properties | 2 +-
.../jdk/nashorn/internal/codegen/Attr.java | 37 +++--
.../internal/codegen/CodeGenerator.java | 57 ++++++--
.../internal/codegen/FinalizeTypes.java | 6 +-
.../internal/codegen/FoldConstants.java | 2 +-
.../jdk/nashorn/internal/codegen/Label.java | 21 ++-
.../jdk/nashorn/internal/codegen/Lower.java | 96 ++++++-------
.../internal/codegen/MethodEmitter.java | 78 ++++++-----
.../nashorn/internal/codegen/Splitter.java | 43 +++---
.../src/jdk/nashorn/internal/ir/Block.java | 20 +--
.../internal/ir/BlockLexicalContext.java | 32 ++---
.../jdk/nashorn/internal/ir/BreakNode.java | 13 +-
.../nashorn/internal/ir/BreakableNode.java | 5 +-
.../src/jdk/nashorn/internal/ir/CallNode.java | 13 +-
.../jdk/nashorn/internal/ir/CatchNode.java | 7 +-
.../jdk/nashorn/internal/ir/ContinueNode.java | 13 +-
.../jdk/nashorn/internal/ir/EmptyNode.java | 9 +-
.../jdk/nashorn/internal/ir/ExecuteNode.java | 17 +--
.../src/jdk/nashorn/internal/ir/ForNode.java | 19 +--
.../jdk/nashorn/internal/ir/FunctionNode.java | 19 ++-
.../src/jdk/nashorn/internal/ir/IfNode.java | 17 +--
.../jdk/nashorn/internal/ir/LabelNode.java | 13 +-
.../internal/ir/LexicalContextNode.java | 11 +-
.../src/jdk/nashorn/internal/ir/LoopNode.java | 13 +-
nashorn/src/jdk/nashorn/internal/ir/Node.java | 9 --
.../jdk/nashorn/internal/ir/ReturnNode.java | 11 +-
.../jdk/nashorn/internal/ir/SplitNode.java | 5 +-
.../{LineNumberNode.java => Statement.java} | 71 +++++-----
.../jdk/nashorn/internal/ir/SwitchNode.java | 5 +-
.../src/jdk/nashorn/internal/ir/Symbol.java | 20 +--
.../jdk/nashorn/internal/ir/ThrowNode.java | 9 +-
.../src/jdk/nashorn/internal/ir/TryNode.java | 15 ++-
.../src/jdk/nashorn/internal/ir/VarNode.java | 30 +++--
.../jdk/nashorn/internal/ir/WhileNode.java | 25 ++--
.../src/jdk/nashorn/internal/ir/WithNode.java | 5 +-
.../nashorn/internal/ir/debug/JSONWriter.java | 34 ++---
.../internal/ir/debug/PrintVisitor.java | 50 +++----
.../ir/visitor/NodeOperatorVisitor.java | 2 +-
.../internal/ir/visitor/NodeVisitor.java | 21 ---
.../jdk/nashorn/internal/objects/Global.java | 1 +
.../nashorn/internal/objects/NativeDebug.java | 1 +
.../jdk/nashorn/internal/parser/Parser.java | 127 ++++++++++--------
.../jdk/nashorn/internal/runtime/Context.java | 3 +-
.../runtime/linker/LinkerCallSite.java | 7 +-
nashorn/src/jdk/nashorn/tools/Shell.java | 1 +
nashorn/test/script/basic/no_line_numbers.js | 125 +++++++++++++++++
.../script/basic/no_line_numbers.js.EXPECTED | 12 ++
47 files changed, 660 insertions(+), 492 deletions(-)
rename nashorn/src/jdk/nashorn/internal/ir/{LineNumberNode.java => Statement.java} (58%)
create mode 100644 nashorn/test/script/basic/no_line_numbers.js
create mode 100644 nashorn/test/script/basic/no_line_numbers.js.EXPECTED
diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties
index e2f39bb7ab0..bd4cf5d3890 100644
--- a/nashorn/make/project.properties
+++ b/nashorn/make/project.properties
@@ -214,7 +214,7 @@ run.test.xms=2G
# -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
# add '-Dtest.js.outofprocess' to run each test in a new sub-process
-run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:-TieredCompilation -ea -Dnashorn.debug=true -Dfile.encoding=UTF-8
+run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dnashorn.debug=true -Dfile.encoding=UTF-8
#-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.main}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java
index a381e58d7aa..8831f75794b 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java
@@ -78,6 +78,7 @@ import jdk.nashorn.internal.ir.PropertyNode;
import jdk.nashorn.internal.ir.ReturnNode;
import jdk.nashorn.internal.ir.RuntimeNode;
import jdk.nashorn.internal.ir.RuntimeNode.Request;
+import jdk.nashorn.internal.ir.Statement;
import jdk.nashorn.internal.ir.SwitchNode;
import jdk.nashorn.internal.ir.Symbol;
import jdk.nashorn.internal.ir.TernaryNode;
@@ -154,7 +155,9 @@ final class Attr extends NodeOperatorVisitor {
@Override
public Node leaveAccessNode(final AccessNode accessNode) {
- //While Object type is assigned here, Access Specialization in FinalizeTypes may narrow this
+ //While Object type is assigned here, Access Specialization in FinalizeTypes may narrow this, that
+ //is why we can't set the access node base to be an object here, that will ruin access specialization
+ //for example for a.x | 17.
return end(ensureSymbol(Type.OBJECT, accessNode));
}
@@ -435,6 +438,7 @@ final class Attr extends NodeOperatorVisitor {
final IdentNode callee = compilerConstant(CALLEE);
VarNode selfInit =
new VarNode(
+ newFunctionNode.getLineNumber(),
newFunctionNode.getToken(),
newFunctionNode.getFinish(),
newFunctionNode.getIdent(),
@@ -442,7 +446,7 @@ final class Attr extends NodeOperatorVisitor {
LOG.info("Accepting self symbol init ", selfInit, " for ", newFunctionNode.getName());
- final List newStatements = new ArrayList<>();
+ final List newStatements = new ArrayList<>();
assert callee.getSymbol() != null && callee.getSymbol().hasSlot();
final IdentNode name = selfInit.getName();
@@ -492,7 +496,7 @@ final class Attr extends NodeOperatorVisitor {
final Symbol pseudoSymbol = pseudoSymbol(name);
LOG.info("IdentNode is property name -> assigning pseudo symbol ", pseudoSymbol);
LOG.unindent();
- return identNode.setSymbol(lc, pseudoSymbol);
+ return end(identNode.setSymbol(lc, pseudoSymbol));
}
final Block block = lc.getCurrentBlock();
@@ -658,7 +662,7 @@ final class Attr extends NodeOperatorVisitor {
if (literalNode instanceof ArrayLiteralNode) {
((ArrayLiteralNode)literalNode).analyze();
}
- return literalNode.setSymbol(getLexicalContext(), symbol);
+ return end(literalNode.setSymbol(getLexicalContext(), symbol));
}
@Override
@@ -779,17 +783,18 @@ final class Attr extends NodeOperatorVisitor {
final IdentNode ident = newVarNode.getName();
final String name = ident.getName();
+ final LexicalContext lc = getLexicalContext();
+ final Symbol symbol = findSymbol(lc.getCurrentBlock(), ident.getName());
+
if (init == null) {
// var x; with no init will be treated like a use of x by
// leaveIdentNode unless we remove the name from the localdef list.
removeLocalDef(name);
- return newVarNode;
+ return newVarNode.setSymbol(lc, symbol);
}
addLocalDef(name);
- final LexicalContext lc = getLexicalContext();
- final Symbol symbol = findSymbol(lc.getCurrentBlock(), ident.getName());
assert symbol != null;
final IdentNode newIdent = (IdentNode)ident.setSymbol(lc, symbol);
@@ -1398,7 +1403,9 @@ final class Attr extends NodeOperatorVisitor {
private FunctionNode finalizeParameters(final FunctionNode functionNode) {
final List newParams = new ArrayList<>();
final boolean isVarArg = functionNode.isVarArg();
+ final int nparams = functionNode.getParameters().size();
+ int specialize = 0;
int pos = 0;
for (final IdentNode param : functionNode.getParameters()) {
final Symbol paramSymbol = functionNode.getBody().getExistingSymbol(param.getName());
@@ -1414,9 +1421,13 @@ final class Attr extends NodeOperatorVisitor {
// if we know that a parameter is only used as a certain type throughout
// this function, we can tell the runtime system that no matter what the
- // call site is, use this information. TODO
- if (!paramSymbol.getSymbolType().isObject()) {
+ // call site is, use this information:
+ // we also need more than half of the parameters to be specializable
+ // for the heuristic to be worth it, and we need more than one use of
+ // the parameter to consider it, i.e. function(x) { call(x); } doens't count
+ if (paramSymbol.getUseCount() > 1 && !paramSymbol.getSymbolType().isObject()) {
LOG.finest("Parameter ", param, " could profit from specialization to ", paramSymbol.getSymbolType());
+ specialize++;
}
newType(paramSymbol, Type.widest(type, paramSymbol.getSymbolType()));
@@ -1429,7 +1440,13 @@ final class Attr extends NodeOperatorVisitor {
pos++;
}
- return functionNode.setParameters(getLexicalContext(), newParams);
+ FunctionNode newFunctionNode = functionNode;
+
+ if (nparams == 0 || (specialize * 2) < nparams) {
+ newFunctionNode = newFunctionNode.clearSnapshot(getLexicalContext());
+ }
+
+ return newFunctionNode.setParameters(getLexicalContext(), newParams);
}
/**
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
index 97219e3db8a..1fae129468d 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
@@ -63,6 +63,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+
import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
import jdk.nashorn.internal.codegen.CompilerConstants.Call;
import jdk.nashorn.internal.codegen.RuntimeCallSite.SpecializedRuntimeNode;
@@ -88,7 +89,6 @@ import jdk.nashorn.internal.ir.IfNode;
import jdk.nashorn.internal.ir.IndexNode;
import jdk.nashorn.internal.ir.LexicalContext;
import jdk.nashorn.internal.ir.LexicalContextNode;
-import jdk.nashorn.internal.ir.LineNumberNode;
import jdk.nashorn.internal.ir.LiteralNode;
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit;
@@ -100,6 +100,7 @@ import jdk.nashorn.internal.ir.ReturnNode;
import jdk.nashorn.internal.ir.RuntimeNode;
import jdk.nashorn.internal.ir.RuntimeNode.Request;
import jdk.nashorn.internal.ir.SplitNode;
+import jdk.nashorn.internal.ir.Statement;
import jdk.nashorn.internal.ir.SwitchNode;
import jdk.nashorn.internal.ir.Symbol;
import jdk.nashorn.internal.ir.TernaryNode;
@@ -191,6 +192,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
/** Current compile unit */
private CompileUnit unit;
+ private int lastLineNumber = -1;
+
/** When should we stop caching regexp expressions in fields to limit bytecode size? */
private static final int MAX_REGEX_FIELDS = 2 * 1024;
@@ -619,6 +622,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
+ lineNumber(breakNode);
+
final BreakableNode breakFrom = getLexicalContext().getBreakable(breakNode.getLabel());
for (int i = 0; i < getLexicalContext().getScopeNestingLevelTo(breakFrom); i++) {
closeWith();
@@ -663,6 +668,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterCallNode(final CallNode callNode) {
+ lineNumber(callNode);
+
final List args = callNode.getArgs();
final Node function = callNode.getFunction();
final Block currentBlock = getLexicalContext().getCurrentBlock();
@@ -836,6 +843,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterContinueNode(final ContinueNode continueNode) {
+ lineNumber(continueNode);
+
final LoopNode continueTo = getLexicalContext().getContinueTo(continueNode.getLabel());
for (int i = 0; i < getLexicalContext().getScopeNestingLevelTo(continueTo); i++) {
closeWith();
@@ -847,11 +856,15 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterEmptyNode(final EmptyNode emptyNode) {
+ lineNumber(emptyNode);
+
return false;
}
@Override
public boolean enterExecuteNode(final ExecuteNode executeNode) {
+ lineNumber(executeNode);
+
final Node expression = executeNode.getExpression();
expression.accept(this);
@@ -860,6 +873,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterForNode(final ForNode forNode) {
+ lineNumber(forNode);
+
final Node test = forNode.getTest();
final Block body = forNode.getBody();
final Node modify = forNode.getModify();
@@ -1148,6 +1163,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterIfNode(final IfNode ifNode) {
+ lineNumber(ifNode);
+
final Node test = ifNode.getTest();
final Block pass = ifNode.getPass();
final Block fail = ifNode.getFail();
@@ -1187,12 +1204,12 @@ final class CodeGenerator extends NodeOperatorVisitor {
return false;
}
- @Override
- public boolean enterLineNumberNode(final LineNumberNode lineNumberNode) {
- final Label label = new Label((String)null);
- method.label(label);
- method.lineNumber(lineNumberNode.getLineNumber(), label);
- return false;
+ private void lineNumber(final Statement statement) {
+ final int lineNumber = statement.getLineNumber();
+ if (lineNumber != lastLineNumber) {
+ method.lineNumber(statement.getLineNumber());
+ }
+ lastLineNumber = lineNumber;
}
/**
@@ -1524,6 +1541,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
+ lineNumber(returnNode);
+
method.registerReturn();
final Type returnType = getLexicalContext().getCurrentFunction().getReturnType();
@@ -1733,6 +1752,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterSplitNode(final SplitNode splitNode) {
+ lineNumber(splitNode);
+
final CompileUnit splitCompileUnit = splitNode.getCompileUnit();
final FunctionNode fn = getLexicalContext().getCurrentFunction();
@@ -1876,6 +1897,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterSwitchNode(final SwitchNode switchNode) {
+ lineNumber(switchNode);
+
final Node expression = switchNode.getExpression();
final Symbol tag = switchNode.getTag();
final boolean allInteger = tag.getSymbolType().isInteger();
@@ -1958,7 +1981,6 @@ final class CodeGenerator extends NodeOperatorVisitor {
method.tableswitch(lo, hi, defaultLabel, table);
} else {
final int[] ints = new int[size];
-
for (int i = 0; i < size; i++) {
ints[i] = values[i];
}
@@ -2004,6 +2026,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterThrowNode(final ThrowNode throwNode) {
+ lineNumber(throwNode);
+
method._new(ECMAException.class).dup();
final Source source = getLexicalContext().getCurrentFunction().getSource();
@@ -2028,6 +2052,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterTryNode(final TryNode tryNode) {
+ lineNumber(tryNode);
+
final Block body = tryNode.getBody();
final List catchBlocks = tryNode.getCatchBlocks();
final Symbol symbol = tryNode.getException();
@@ -2124,12 +2150,15 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterVarNode(final VarNode varNode) {
+
final Node init = varNode.getInit();
if (init == null) {
return false;
}
+ lineNumber(varNode);
+
final Symbol varSymbol = varNode.getSymbol();
assert varSymbol != null : "variable node " + varNode + " requires a symbol";
@@ -2162,6 +2191,8 @@ final class CodeGenerator extends NodeOperatorVisitor {
@Override
public boolean enterWhileNode(final WhileNode whileNode) {
+ lineNumber(whileNode);
+
final Node test = whileNode.getTest();
final Block body = whileNode.getBody();
final Label breakLabel = whileNode.getBreakLabel();
@@ -2184,7 +2215,7 @@ final class CodeGenerator extends NodeOperatorVisitor {
}
private void closeWith() {
- if(method.hasScope()) {
+ if (method.hasScope()) {
method.loadCompilerConstant(SCOPE);
method.invoke(ScriptRuntime.CLOSE_WITH);
method.storeCompilerConstant(SCOPE);
@@ -2227,7 +2258,7 @@ final class CodeGenerator extends NodeOperatorVisitor {
// Always process body
body.accept(this);
- if(hasScope) {
+ if (hasScope) {
// Ensure we always close the WithObject
final Label endLabel = new Label("with_end");
final Label catchLabel = new Label("with_catch");
@@ -3010,6 +3041,7 @@ final class CodeGenerator extends NodeOperatorVisitor {
* @param block the block we are in
* @param ident identifier for block or function where applicable
*/
+ @SuppressWarnings("resource")
private void printSymbols(final Block block, final String ident) {
if (!compiler.getEnv()._print_symbols) {
return;
@@ -3190,9 +3222,6 @@ final class CodeGenerator extends NodeOperatorVisitor {
return;
}
- //System.err.println("Store with out discard that shouldn't just return " + assignNode);
- //new Throwable().printStackTrace();
-
final Symbol symbol = assignNode.getSymbol();
if (symbol.hasSlot()) {
method.dup().store(symbol);
@@ -3288,7 +3317,7 @@ final class CodeGenerator extends NodeOperatorVisitor {
// Such immediately-called functions are invoked using INVOKESTATIC (see enterFunctionNode() of the embedded
// visitor of enterCallNode() for details), and if they don't need a callee, they don't have it on their
// static method's parameter list.
- if(lc.getOutermostFunction() == functionNode ||
+ if (lc.getOutermostFunction() == functionNode ||
(!functionNode.needsCallee()) && lc.isFunctionDefinedInCurrentCall(originalFunctionNode)) {
return;
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java
index 1b6e3c161df..e7ac516b91c 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java
@@ -228,19 +228,19 @@ final class FinalizeTypes extends NodeOperatorVisitor {
}
@Override
- public Node leaveBIT_AND(BinaryNode binaryNode) {
+ public Node leaveBIT_AND(final BinaryNode binaryNode) {
assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : "int coercion expected: " + binaryNode.getSymbol();
return leaveBinary(binaryNode, Type.INT, Type.INT);
}
@Override
- public Node leaveBIT_OR(BinaryNode binaryNode) {
+ public Node leaveBIT_OR(final BinaryNode binaryNode) {
assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : "int coercion expected: " + binaryNode.getSymbol();
return leaveBinary(binaryNode, Type.INT, Type.INT);
}
@Override
- public Node leaveBIT_XOR(BinaryNode binaryNode) {
+ public Node leaveBIT_XOR(final BinaryNode binaryNode) {
assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : "int coercion expected: " + binaryNode.getSymbol();
return leaveBinary(binaryNode, Type.INT, Type.INT);
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
index 92286c2bf63..686c9836da6 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java
@@ -88,7 +88,7 @@ final class FoldConstants extends NodeVisitor {
if (test instanceof LiteralNode) {
final Block shortCut = ((LiteralNode>)test).isTrue() ? ifNode.getPass() : ifNode.getFail();
if (shortCut != null) {
- return new ExecuteNode(shortCut);
+ return new ExecuteNode(shortCut.getLineNumber(), shortCut.getToken(), shortCut.getFinish(), shortCut);
}
return new EmptyNode(ifNode);
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Label.java b/nashorn/src/jdk/nashorn/internal/codegen/Label.java
index 9d28caafd1d..4c401370041 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/Label.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Label.java
@@ -27,6 +27,7 @@ package jdk.nashorn.internal.codegen;
import java.util.ArrayDeque;
import jdk.nashorn.internal.codegen.types.Type;
+import jdk.nashorn.internal.runtime.Debug;
/**
* Abstraction for labels, separating a label from the underlying
@@ -35,13 +36,16 @@ import jdk.nashorn.internal.codegen.types.Type;
*
* see -Dnashorn.codegen.debug, --log=codegen
*/
-public class Label extends jdk.internal.org.objectweb.asm.Label {
+public final class Label {
/** Name of this label */
private final String name;
/** Type stack at this label */
private ArrayDeque stack;
+ /** ASM representation of this label */
+ private jdk.internal.org.objectweb.asm.Label label;
+
/**
* Constructor
*
@@ -62,6 +66,14 @@ public class Label extends jdk.internal.org.objectweb.asm.Label {
this.name = label.name;
}
+
+ jdk.internal.org.objectweb.asm.Label getLabel() {
+ if (this.label == null) {
+ this.label = new jdk.internal.org.objectweb.asm.Label();
+ }
+ return label;
+ }
+
ArrayDeque getStack() {
return stack;
}
@@ -72,12 +84,7 @@ public class Label extends jdk.internal.org.objectweb.asm.Label {
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder();
- String s = super.toString();
- s = s.substring(1, s.length());
- sb.append(name).append('_').append(Long.toHexString(Long.parseLong(s)));
-
- return sb.toString();
+ return name + '_' + Debug.id(this);
}
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java
index 6f55841ebc9..23e91b63026 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java
@@ -32,6 +32,7 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.THIS;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+
import jdk.nashorn.internal.ir.BaseNode;
import jdk.nashorn.internal.ir.BinaryNode;
import jdk.nashorn.internal.ir.Block;
@@ -49,16 +50,15 @@ import jdk.nashorn.internal.ir.IdentNode;
import jdk.nashorn.internal.ir.IfNode;
import jdk.nashorn.internal.ir.LabelNode;
import jdk.nashorn.internal.ir.LexicalContext;
-import jdk.nashorn.internal.ir.LineNumberNode;
import jdk.nashorn.internal.ir.LiteralNode;
import jdk.nashorn.internal.ir.LoopNode;
import jdk.nashorn.internal.ir.Node;
import jdk.nashorn.internal.ir.ReturnNode;
+import jdk.nashorn.internal.ir.Statement;
import jdk.nashorn.internal.ir.SwitchNode;
import jdk.nashorn.internal.ir.Symbol;
import jdk.nashorn.internal.ir.ThrowNode;
import jdk.nashorn.internal.ir.TryNode;
-import jdk.nashorn.internal.ir.UnaryNode;
import jdk.nashorn.internal.ir.VarNode;
import jdk.nashorn.internal.ir.WhileNode;
import jdk.nashorn.internal.ir.WithNode;
@@ -93,21 +93,25 @@ final class Lower extends NodeOperatorVisitor {
super(new BlockLexicalContext() {
@Override
- public List popStatements() {
- List newStatements = new ArrayList<>();
+ public List popStatements() {
+ final List newStatements = new ArrayList<>();
boolean terminated = false;
- final List statements = super.popStatements();
- for (final Node statement : statements) {
+ final List statements = super.popStatements();
+ for (final Statement statement : statements) {
if (!terminated) {
newStatements.add(statement);
- if (statement.isTerminal()) {
+ if (statement.isTerminal() || statement instanceof BreakNode || statement instanceof ContinueNode) { //TODO hasGoto? But some Loops are hasGoto too - why?
terminated = true;
}
} else {
- if (statement instanceof VarNode) {
- newStatements.add(((VarNode)statement).setInit(null));
- }
+ statement.accept(new NodeVisitor() {
+ @Override
+ public boolean enterVarNode(final VarNode varNode) {
+ newStatements.add(varNode.setInit(null));
+ return false;
+ }
+ });
}
}
return newStatements;
@@ -120,7 +124,7 @@ final class Lower extends NodeOperatorVisitor {
final LexicalContext lc = getLexicalContext();
final FunctionNode function = lc.getCurrentFunction();
if (lc.isFunctionBody() && function.isProgram() && !function.hasDeclaredFunctions()) {
- new ExecuteNode(block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this);
+ new ExecuteNode(block.getLineNumber(), block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this);
}
return true;
}
@@ -132,19 +136,20 @@ final class Lower extends NodeOperatorVisitor {
final BlockLexicalContext lc = (BlockLexicalContext)getLexicalContext();
- Node last = lc.getLastStatement();
+ Statement last = lc.getLastStatement();
if (lc.isFunctionBody()) {
final FunctionNode currentFunction = getLexicalContext().getCurrentFunction();
final boolean isProgram = currentFunction.isProgram();
final ReturnNode returnNode = new ReturnNode(
+ last == null ? block.getLineNumber() : last.getLineNumber(), //TODO?
currentFunction.getToken(),
currentFunction.getFinish(),
isProgram ?
compilerConstant(RETURN) :
LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED));
- last = returnNode.accept(this);
+ last = (Statement)returnNode.accept(this);
}
if (last != null && last.isTerminal()) {
@@ -238,12 +243,6 @@ final class Lower extends NodeOperatorVisitor {
return addStatement(labelNode);
}
- @Override
- public boolean enterLineNumberNode(final LineNumberNode lineNumberNode) {
- addStatement(lineNumberNode); // don't put it in lastStatement cache
- return false;
- }
-
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
addStatement(returnNode); //ReturnNodes are always terminal, marked as such in constructor
@@ -271,10 +270,10 @@ final class Lower extends NodeOperatorVisitor {
});
}
- private static List copyFinally(final Block finallyBody) {
- final List newStatements = new ArrayList<>();
- for (final Node statement : finallyBody.getStatements()) {
- newStatements.add(ensureUniqueLabelsIn(statement));
+ private static List copyFinally(final Block finallyBody) {
+ final List newStatements = new ArrayList<>();
+ for (final Statement statement : finallyBody.getStatements()) {
+ newStatements.add((Statement)ensureUniqueLabelsIn(statement));
if (statement.hasTerminalFlags()) {
return newStatements;
}
@@ -283,16 +282,17 @@ final class Lower extends NodeOperatorVisitor {
}
private Block catchAllBlock(final TryNode tryNode) {
- final long token = tryNode.getToken();
- final int finish = tryNode.getFinish();
+ final int lineNumber = tryNode.getLineNumber();
+ final long token = tryNode.getToken();
+ final int finish = tryNode.getFinish();
final IdentNode exception = new IdentNode(token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all"));
- final Block catchBody = new Block(token, finish, new ThrowNode(token, finish, new IdentNode(exception))).
+ final Block catchBody = new Block(lineNumber, token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception))).
setIsTerminal(getLexicalContext(), true); //ends with throw, so terminal
- final CatchNode catchAllNode = new CatchNode(token, finish, new IdentNode(exception), null, catchBody);
- final Block catchAllBlock = new Block(token, finish, catchAllNode);
+ final CatchNode catchAllNode = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody);
+ final Block catchAllBlock = new Block(lineNumber, token, finish, catchAllNode);
//catchallblock -> catchallnode (catchnode) -> exception -> throw
@@ -304,7 +304,7 @@ final class Lower extends NodeOperatorVisitor {
return new IdentNode(functionNode.getToken(), functionNode.getFinish(), cc.symbolName());
}
- private static boolean isTerminal(final List statements) {
+ private static boolean isTerminal(final List statements) {
return !statements.isEmpty() && statements.get(statements.size() - 1).hasTerminalFlags();
}
@@ -316,7 +316,7 @@ final class Lower extends NodeOperatorVisitor {
* @return new try node after splicing finally code (same if nop)
*/
private Node spliceFinally(final TryNode tryNode, final List rethrows, final Block finallyBody) {
- final int finish = tryNode.getFinish();
+ final int finish = tryNode.getFinish();
assert tryNode.getFinallyBody() == null;
@@ -338,11 +338,11 @@ final class Lower extends NodeOperatorVisitor {
@Override
public Node leaveThrowNode(final ThrowNode throwNode) {
if (rethrows.contains(throwNode)) {
- final List newStatements = copyFinally(finallyBody);
+ final List newStatements = copyFinally(finallyBody);
if (!isTerminal(newStatements)) {
newStatements.add(throwNode);
}
- return new Block(throwNode.getToken(), throwNode.getFinish(), newStatements);
+ return new Block(throwNode.getLineNumber(), throwNode.getToken(), throwNode.getFinish(), newStatements);
}
return throwNode;
}
@@ -360,14 +360,14 @@ final class Lower extends NodeOperatorVisitor {
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
final Node expr = returnNode.getExpression();
- final List newStatements = new ArrayList<>();
+ final List newStatements = new ArrayList<>();
final Node resultNode;
if (expr != null) {
//we need to evaluate the result of the return in case it is complex while
//still in the try block, store it in a result value and return it afterwards
resultNode = new IdentNode(Lower.this.compilerConstant(RETURN));
- newStatements.add(new ExecuteNode(new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
+ newStatements.add(new ExecuteNode(returnNode.getLineNumber(), returnNode.getToken(), returnNode.getFinish(), new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
} else {
resultNode = null;
}
@@ -377,16 +377,16 @@ final class Lower extends NodeOperatorVisitor {
newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode));
}
- return new ExecuteNode(new Block(returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements));
+ return new ExecuteNode(returnNode.getLineNumber(), returnNode.getToken(), returnNode.getFinish(), new Block(returnNode.getLineNumber(), returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements));
}
- private Node copy(final Node endpoint, final Node targetNode) {
+ private Node copy(final Statement endpoint, final Node targetNode) {
if (!insideTry.contains(targetNode)) {
- final List newStatements = copyFinally(finallyBody);
+ final List newStatements = copyFinally(finallyBody);
if (!isTerminal(newStatements)) {
newStatements.add(endpoint);
}
- return new ExecuteNode(new Block(endpoint.getToken(), finish, newStatements));
+ return new ExecuteNode(endpoint.getLineNumber(), endpoint.getToken(), endpoint.getFinish(), new Block(endpoint.getLineNumber(), endpoint.getToken(), finish, newStatements));
}
return endpoint;
}
@@ -394,7 +394,7 @@ final class Lower extends NodeOperatorVisitor {
addStatement(newTryNode);
for (final Node statement : finallyBody.getStatements()) {
- addStatement(statement);
+ addStatement((Statement)statement);
}
return newTryNode;
@@ -448,7 +448,7 @@ final class Lower extends NodeOperatorVisitor {
if (tryNode.getCatchBlocks().isEmpty()) {
newTryNode = tryNode.setFinallyBody(null);
} else {
- Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), new ArrayList(Arrays.asList(tryNode.setFinallyBody(null))));
+ Block outerBody = new Block(tryNode.getLineNumber(), tryNode.getToken(), tryNode.getFinish(), new ArrayList(Arrays.asList(tryNode.setFinallyBody(null))));
newTryNode = tryNode.setBody(outerBody).setCatchBlocks(null);
}
@@ -465,7 +465,7 @@ final class Lower extends NodeOperatorVisitor {
public Node leaveVarNode(final VarNode varNode) {
addStatement(varNode);
if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && getLexicalContext().getCurrentFunction().isProgram()) {
- new ExecuteNode(varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
+ new ExecuteNode(varNode.getLineNumber(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
}
return varNode;
}
@@ -477,7 +477,7 @@ final class Lower extends NodeOperatorVisitor {
if (conservativeAlwaysTrue(test)) {
//turn it into a for node without a test.
- final ForNode forNode = (ForNode)new ForNode(whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this);
+ final ForNode forNode = (ForNode)new ForNode(whileNode.getLineNumber(), whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this);
getLexicalContext().replace(whileNode, forNode);
return forNode;
}
@@ -490,16 +490,6 @@ final class Lower extends NodeOperatorVisitor {
return addStatement(withNode);
}
- @Override
- public Node leaveDELETE(final UnaryNode unaryNode) {
- final Node rhs = unaryNode.rhs();
- if (rhs instanceof IdentNode || rhs instanceof BaseNode) {
- return unaryNode;
- }
- addStatement(new ExecuteNode(rhs));
- return LiteralNode.newInstance(unaryNode, true);
- }
-
/**
* Given a function node that is a callee in a CallNode, replace it with
* the appropriate marker function. This is used by {@link CodeGenerator}
@@ -616,7 +606,7 @@ final class Lower extends NodeOperatorVisitor {
}
- private Node addStatement(final Node statement) {
+ private Node addStatement(final Statement statement) {
((BlockLexicalContext)getLexicalContext()).appendStatement(statement);
return statement;
}
diff --git a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java
index 4fbb57a68cf..549e264899f 100644
--- a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java
+++ b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java
@@ -71,6 +71,7 @@ import java.util.ArrayDeque;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
+
import jdk.internal.dynalink.support.NameCodec;
import jdk.internal.org.objectweb.asm.Handle;
import jdk.internal.org.objectweb.asm.MethodVisitor;
@@ -189,7 +190,7 @@ public class MethodEmitter implements Emitter {
@Override
public void begin() {
classEmitter.beginMethod(this);
- stack = new ArrayDeque<>();
+ newStack();
method.visitCode();
}
@@ -205,6 +206,10 @@ public class MethodEmitter implements Emitter {
classEmitter.endMethod(this);
}
+ private void newStack() {
+ stack = new ArrayDeque<>();
+ }
+
@Override
public String toString() {
return "methodEmitter: " + (functionNode == null ? method : functionNode.getName()).toString() + ' ' + Debug.id(this);
@@ -484,7 +489,7 @@ public class MethodEmitter implements Emitter {
name = THIS_DEBUGGER.symbolName();
}
- method.visitLocalVariable(name, symbol.getSymbolType().getDescriptor(), null, start, end, symbol.getSlot());
+ method.visitLocalVariable(name, symbol.getSymbolType().getDescriptor(), null, start.getLabel(), end.getLabel(), symbol.getSlot());
}
/**
@@ -508,17 +513,6 @@ public class MethodEmitter implements Emitter {
return invoke(virtualCallNoLookup(StringBuilder.class, "append", StringBuilder.class, String.class));
}
- /**
- * Associate a variable with a given range
- *
- * @param name name of the variable
- * @param start start
- * @param end end
- */
- void markerVariable(final String name, final Label start, final Label end) {
- method.visitLocalVariable(name, Type.OBJECT.getDescriptor(), null, start, end, 0);
- }
-
/**
* Pops two integer types from the stack, performs a bitwise and and pushes
* the result
@@ -626,7 +620,7 @@ public class MethodEmitter implements Emitter {
* @param typeDescriptor type descriptor for exception
*/
void _try(final Label entry, final Label exit, final Label recovery, final String typeDescriptor) {
- method.visitTryCatchBlock(entry, exit, recovery, typeDescriptor);
+ method.visitTryCatchBlock(entry.getLabel(), exit.getLabel(), recovery.getLabel(), typeDescriptor);
}
/**
@@ -638,7 +632,7 @@ public class MethodEmitter implements Emitter {
* @param clazz exception class
*/
void _try(final Label entry, final Label exit, final Label recovery, final Class> clazz) {
- method.visitTryCatchBlock(entry, exit, recovery, CompilerConstants.className(clazz));
+ method.visitTryCatchBlock(entry.getLabel(), exit.getLabel(), recovery.getLabel(), CompilerConstants.className(clazz));
}
/**
@@ -1228,6 +1222,14 @@ public class MethodEmitter implements Emitter {
return invoke(INVOKEINTERFACE, className, methodName, methodDescriptor, true);
}
+ static jdk.internal.org.objectweb.asm.Label[] getLabels(final Label... table) {
+ final jdk.internal.org.objectweb.asm.Label[] internalLabels = new jdk.internal.org.objectweb.asm.Label[table.length];
+ for (int i = 0; i < table.length; i++) {
+ internalLabels[i] = table[i].getLabel();
+ }
+ return internalLabels;
+ }
+
/**
* Generate a lookup switch, popping the switch value from the stack
*
@@ -1235,10 +1237,10 @@ public class MethodEmitter implements Emitter {
* @param values case values for the table
* @param table default label
*/
- void lookupswitch(final Label defaultLabel, final int[] values, final Label[] table) {
+ void lookupswitch(final Label defaultLabel, final int[] values, final Label... table) {//Collection