Skip to content

Commit 508d0a7

Browse files
committed
better setting of modifiers for Class.getMethod
1 parent f558699 commit 508d0a7

File tree

1 file changed

+14
-9
lines changed
  • sources/net.sf.j2s.java.core/src/java/lang

1 file changed

+14
-9
lines changed

sources/net.sf.j2s.java.core/src/java/lang/Class.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,20 +1955,25 @@ public Method getMethod(String name, Class<?>... paramTypes) throws NoSuchMethod
19551955
// note that we cannot check the method at this time, as it could be an interface,
19561956
// and interfaces will not have elaborated methods.
19571957

1958-
Method m = new Method(this, name, paramTypes, null, null, 0);
1958+
Method m = new Method(this, name, paramTypes, null, null, Modifier.PUBLIC);
19591959
if (!isInterface()) {
1960-
Object o = null;
1960+
Object o = $clazz$;
1961+
boolean isStatic = false;
19611962
String qname = m.getSignature();
19621963
/**
19631964
* @j2sNative
19641965
*
1965-
* o = this.$clazz$;
1966-
* o = o[qname] || o.prototype && o.prototype[qname];
1966+
* if (o[qname]) {
1967+
* isStatic = true;
1968+
* o = o[qname];
1969+
* } else {
1970+
* o = o.prototype && o.prototype[qname];
1971+
* }
19671972
*
19681973
*/
1969-
m._setJSMethod(o);
19701974
if (o == null)
1971-
throw new NoSuchMethodException(getName() + "." + qname);
1975+
throw new NoSuchMethodException(getName() + "." + qname);
1976+
m._setJSMethod(o, (isStatic ? Modifier.STATIC : 0));
19721977
}
19731978
return m;
19741979
// /**
@@ -3063,7 +3068,7 @@ private Method[] privateGetPublicMethods() {
30633068
*/
30643069

30653070
Method m = new Method(this, attr, UNKNOWN_PARAMETERS, Void.class, NO_PARAMETERS, Modifier.PUBLIC);
3066-
m._setJSMethod(o);
3071+
m._setJSMethod(o, Modifier.PUBLIC);
30673072

30683073
/**
30693074
* @j2sNative
@@ -3075,8 +3080,8 @@ private Method[] privateGetPublicMethods() {
30753080
* "function" && o.exName && !o.__CLASS_NAME__ &&
30763081
* o.exClazz == this.$clazz$) {
30773082
*/
3078-
m = new Method(this, attr, UNKNOWN_PARAMETERS, Void.class, NO_PARAMETERS, Modifier.PUBLIC | Modifier.STATIC);
3079-
m._setJSMethod(o);
3083+
m = new Method(this, attr, UNKNOWN_PARAMETERS, Void.class, NO_PARAMETERS, Modifier.PUBLIC);
3084+
m._setJSMethod(o, Modifier.STATIC);
30803085
/**
30813086
* @j2sNative
30823087
*

0 commit comments

Comments
 (0)