Skip to content

Commit 24f811a

Browse files
committed
ClassLoader elaborated for assertion
1 parent 2184ae3 commit 24f811a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTKeywordVisitor.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,23 @@ public class ASTKeywordVisitor extends ASTEmptyVisitor {
163163
class StaticBuffer {
164164
private StringBuffer buf;
165165
private String added = "";
166-
public StaticBuffer() {
166+
167+
boolean hasAssert;
168+
169+
StaticBuffer() {
167170
buf = new StringBuffer();
168171
}
169-
public StaticBuffer append(String s) {
172+
173+
StaticBuffer append(String s) {
170174
buf.append(s);
171175
return this;
172176
}
177+
173178
public String toString() {
174-
return added + buf;
179+
return (hasAssert ? "C$.$_ASSERT_ENABLED_ = ClassLoader.$getClassAssertionStatus(C$);\r\n" : "") + added + buf;
175180
}
176-
public void addType(String name) {
181+
182+
void addType(String name) {
177183
char a = name.charAt(0);
178184
// note that this character may not be in the phrase "new Int Array"
179185
if (added.indexOf(a) >= 0)

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ public boolean visit(AssertStatement node) {
369369
msg.accept(this);
370370
}
371371
buffer.append("});\r\n");
372+
staticFieldDefBuffer.hasAssert = true;
372373
return false;
373374
}
374375

sources/net.sf.j2s.core/test/dev/js/j2sSwingJS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ var extendObject = function(clazz) {
977977
// BH allows @j2sNative access without super constructor
978978
Clazz.clone = function(me) {
979979
return appendMap(me.__ARRAYTYPE ? Clazz.newArray$(me.__BASECLASS, me.__ARRAYTYPE, -1, [-2, me])
980-
: new me.constructor([Clazz.inheritArgs]), me);
980+
: new me.constructor(Clazz.inheritArgs), me);
981981
}
982982
/*
983983
* Methods for thread in Object

0 commit comments

Comments
 (0)