Fixes for NervousText example.

This commit is contained in:
norris%netscape.com 2000-03-09 21:50:14 +00:00
Родитель 5d42d30699
Коммит 530119248e
8 изменённых файлов: 48 добавлений и 18 удалений

Просмотреть файл

@ -294,7 +294,7 @@ public class FunctionObject extends NativeFunction {
* @param name the name of the methods to find
* @return an array of the found methods, or null if no methods
* by that name were found.
* @see java.lang.Class#getDeclaredMethods
* @see java.lang.Class#getMethods
*/
public static Method[] findMethods(Class clazz, String name) {
return findMethods(getMethodList(clazz), name);
@ -335,10 +335,22 @@ public class FunctionObject extends NativeFunction {
Method[] cached = methodsCache; // get once to avoid synchronization
if (cached != null && cached[0].getDeclaringClass() == clazz)
return cached;
Method[] methods = clazz.getDeclaredMethods();
boolean getMethodsCalled = false;
Method[] methods;
try {
// getDeclaredMethods may be rejected by the security manager
methods = clazz.getDeclaredMethods();
} catch (SecurityException e) {
// but getMethods is more expensive
getMethodsCalled = true;
methods = clazz.getMethods();
}
int count = 0;
for (int i=0; i < methods.length; i++) {
if (!Modifier.isPublic(methods[i].getModifiers())) {
if (getMethodsCalled
? !Modifier.isPublic(methods[i].getModifiers())
: methods[i].getDeclaringClass() != clazz)
{
methods[i] = null;
} else {
count++;

Просмотреть файл

@ -1470,7 +1470,7 @@ public class Codegen extends Interpreter {
variableObjectLocal = reserveWordLocal(2);
thisObjLocal = reserveWordLocal(3);
if (!cx.hasCompileFunctionsWithDynamicScope()) {
if (inFunction && !cx.hasCompileFunctionsWithDynamicScope()) {
aload(funObjLocal);
classFile.add(ByteCode.INVOKEINTERFACE,
"org/mozilla/javascript/Scriptable",

Просмотреть файл

@ -76,7 +76,8 @@ public class Main {
*
*/
public static String[] processOptions(Context cx, String args[]) {
cx.setTargetPackage(""); // default to no package
cx.setTargetPackage(""); // default to no package
cx.setGeneratingDebug(false); // default to no symbols
for (int i=0; i < args.length; i++) {
String arg = args[i];
if (!arg.startsWith("-")) {
@ -98,7 +99,7 @@ public class Main {
cx.setOptimizationLevel(optLevel);
continue;
}
if (arg.equals("-debuglevel") && ++i < args.length) {
if (false && arg.equals("-debuglevel") && ++i < args.length) {
int debugLevel = Integer.parseInt(args[i]);
cx.setDebugLevel(debugLevel);
continue;

Просмотреть файл

@ -90,12 +90,14 @@ msg.uncaughtJSException =\
msg.jsc.usage =\
Didn''t understand "{0}". \n\
Valid arguments are: \n\
\ -version 100|110|120|130 \n\
\ -version 100|110|120|130|140|150 \n\
\ -opt [1-9] \n\
\ -debug \n\
\ -debuglevel [0-9]\n\
\ -nosource \n\
\ -o outfile.class
\ -o outfile.class \n\
\ -package packageName \n\
\ -extends extendsClassName \n\
\ -implements implementsClassName
msg.no.file =\

Просмотреть файл

@ -294,7 +294,7 @@ public class FunctionObject extends NativeFunction {
* @param name the name of the methods to find
* @return an array of the found methods, or null if no methods
* by that name were found.
* @see java.lang.Class#getDeclaredMethods
* @see java.lang.Class#getMethods
*/
public static Method[] findMethods(Class clazz, String name) {
return findMethods(getMethodList(clazz), name);
@ -335,10 +335,22 @@ public class FunctionObject extends NativeFunction {
Method[] cached = methodsCache; // get once to avoid synchronization
if (cached != null && cached[0].getDeclaringClass() == clazz)
return cached;
Method[] methods = clazz.getDeclaredMethods();
boolean getMethodsCalled = false;
Method[] methods;
try {
// getDeclaredMethods may be rejected by the security manager
methods = clazz.getDeclaredMethods();
} catch (SecurityException e) {
// but getMethods is more expensive
getMethodsCalled = true;
methods = clazz.getMethods();
}
int count = 0;
for (int i=0; i < methods.length; i++) {
if (!Modifier.isPublic(methods[i].getModifiers())) {
if (getMethodsCalled
? !Modifier.isPublic(methods[i].getModifiers())
: methods[i].getDeclaringClass() != clazz)
{
methods[i] = null;
} else {
count++;

Просмотреть файл

@ -1470,7 +1470,7 @@ public class Codegen extends Interpreter {
variableObjectLocal = reserveWordLocal(2);
thisObjLocal = reserveWordLocal(3);
if (!cx.hasCompileFunctionsWithDynamicScope()) {
if (inFunction && !cx.hasCompileFunctionsWithDynamicScope()) {
aload(funObjLocal);
classFile.add(ByteCode.INVOKEINTERFACE,
"org/mozilla/javascript/Scriptable",

Просмотреть файл

@ -76,7 +76,8 @@ public class Main {
*
*/
public static String[] processOptions(Context cx, String args[]) {
cx.setTargetPackage(""); // default to no package
cx.setTargetPackage(""); // default to no package
cx.setGeneratingDebug(false); // default to no symbols
for (int i=0; i < args.length; i++) {
String arg = args[i];
if (!arg.startsWith("-")) {
@ -98,7 +99,7 @@ public class Main {
cx.setOptimizationLevel(optLevel);
continue;
}
if (arg.equals("-debuglevel") && ++i < args.length) {
if (false && arg.equals("-debuglevel") && ++i < args.length) {
int debugLevel = Integer.parseInt(args[i]);
cx.setDebugLevel(debugLevel);
continue;

Просмотреть файл

@ -90,12 +90,14 @@ msg.uncaughtJSException =\
msg.jsc.usage =\
Didn''t understand "{0}". \n\
Valid arguments are: \n\
\ -version 100|110|120|130 \n\
\ -version 100|110|120|130|140|150 \n\
\ -opt [1-9] \n\
\ -debug \n\
\ -debuglevel [0-9]\n\
\ -nosource \n\
\ -o outfile.class
\ -o outfile.class \n\
\ -package packageName \n\
\ -extends extendsClassName \n\
\ -implements implementsClassName
msg.no.file =\