X Tutup
Skip to content

Commit 2255b09

Browse files
author
zhourenjian
committed
Fixing bug of ClazzLoader and other core classes
1 parent ff7bec7 commit 2255b09

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

sources/net.sf.j2s.java.core/src/java/lang/ClassLoader.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,26 +2074,34 @@ ClazzLoader.load = function (musts, clazz, optionals, declaration) {
20742074
return;
20752075
//*/
20762076
}
2077-
var okToInit = true;
2077+
//var okToInit = true;
20782078
if (musts != null && musts.length != 0) {
20792079
ClazzLoader.unwrapArray (musts);
20802080
for (var i = 0; i < musts.length; i++) {
20812081
var name = musts[i];
20822082
if (name == null || name.length == 0) {
20832083
continue;
20842084
}
2085+
var n = ClazzLoader.findClass (name);
20852086
if (ClazzLoader.isClassDefined (name)
20862087
|| ClazzLoader.isClassExcluded (name)) {
2088+
if (n != null // non-system classes
2089+
&& n.status != ClazzNode.STATUS_OPTIONALS_LOADED) {
2090+
ClazzLoader.addChildClassNode (node, n, 1);
2091+
}
20872092
continue;
20882093
}
2089-
okToInit = false;
2090-
var n = ClazzLoader.findClass (name);
2094+
//okToInit = false;
20912095
if (n == null) {
20922096
n = new ClazzNode ();
20932097
n.name = musts[i];
20942098
n.status = ClazzNode.STATUS_KNOWN;
2099+
ClazzLoader.addChildClassNode (node, n, 1);
2100+
} else {
2101+
if (n.status != ClazzNode.STATUS_OPTIONALS_LOADED) {
2102+
ClazzLoader.addChildClassNode (node, n, 1);
2103+
}
20952104
}
2096-
ClazzLoader.addChildClassNode (node, n, 1);
20972105
}
20982106
}
20992107

@@ -2121,29 +2129,33 @@ ClazzLoader.load = function (musts, clazz, optionals, declaration) {
21212129
node.status = ClazzNode.STATUS_CONTENT_LOADED;
21222130
}
21232131

2124-
var isOptionalsOK = true;
2132+
//var isOptionalsOK = true;
21252133
if (optionals != null && optionals.length != 0) {
21262134
ClazzLoader.unwrapArray (optionals);
21272135
for (var i = 0; i < optionals.length; i++) {
21282136
var name = optionals[i];
21292137
if (name == null || name.length == 0) {
21302138
continue;
21312139
}
2132-
/*
2140+
var n = ClazzLoader.findClass (name);
21332141
if (ClazzLoader.isClassDefined (name)
21342142
|| ClazzLoader.isClassExcluded (name)) {
2143+
if (n != null // non-system classes
2144+
&& n.status != ClazzNode.STATUS_OPTIONALS_LOADED) {
2145+
ClazzLoader.addChildClassNode (node, n, -1);
2146+
}
21352147
continue;
21362148
}
2137-
//*/
2138-
isOptionalsOK = false;
2139-
var n = ClazzLoader.findClass (name);
2149+
//isOptionalsOK = false;
21402150
if (n == null) {
21412151
n = new ClazzNode ();
21422152
n.name = optionals[i];
21432153
n.status = ClazzNode.STATUS_KNOWN;
2144-
}
2145-
if (n.status != ClazzNode.STATUS_OPTIONALS_LOADED) {
21462154
ClazzLoader.addChildClassNode (node, n, -1);
2155+
} else {
2156+
if (n.status != ClazzNode.STATUS_OPTIONALS_LOADED) {
2157+
ClazzLoader.addChildClassNode (node, n, -1);
2158+
}
21472159
}
21482160
}
21492161
}

sources/net.sf.j2s.java.core/src/java/lang/reflect/Method.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public int hashCode() {
352352
* m = this.clazz[this.getName ()];
353353
* }
354354
* if (m != null) {
355-
* m.apply(receiver,args);
355+
* return m.apply(receiver,args);
356356
* } else {
357357
* // should never reach here!
358358
* }

0 commit comments

Comments
 (0)
X Tutup