Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5de496

Browse files
committed
j2sClazz fix inner class object as parameter in reflection
// BH 2022.09.08 Fix new Test_Inner().getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName()
1 parent 2a80667 commit d5de496

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220827143852
1+
20220831192432
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220827143852
1+
20220831192432
123 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/test/Test_Inner.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public String getString() {
3535
return "Test_Inner";
3636
}
3737

38-
class Test_Abstract_a extends Test_ {
38+
public class Test_Abstract_a extends Test_ {
3939

40-
void testing() {
40+
public void testing() {
4141
System.out.println("this is " + a);
4242
assert (a == "a string");
4343
System.out.println(showt2());
@@ -73,17 +73,38 @@ public String showt2() {
7373
}
7474

7575

76+
public void testDollar(Test_Abstract_a abs) {
77+
78+
}
79+
7680
public static void main(String[] args) {
7781
Test_Inner inner = new Test_Inner(6) {};
82+
try {
83+
System.out.println(inner.getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName());
84+
} catch (NoSuchMethodException | SecurityException e) {
85+
// TODO Auto-generated catch block
86+
e.printStackTrace();
87+
}
7888
inner.showt2();
7989
new Test_Inner(3) {}.showt2();
8090
System.out.println(inner.t_test);
8191
System.out.println("new Test_Inner(){}.t_test=" + new Test_Inner(7) {}.t_test);
8292
Test_Abstract_a abs = inner.new Test_Abstract_a();
83-
System.out.println(new Test_Abstract_a[] {abs}.getClass().getName());
84-
abs.testing();
93+
String s = abs.getClass().getName();
94+
String s1 = new Test_Abstract_a[] {abs}.getClass().getName();
95+
System.out.print("checking inner$");
96+
assert(s.equals("test.Test_Inner$Test_Abstract_a"));
97+
assert(s1.equals("[Ltest.Test_Inner$Test_Abstract_a;"));
98+
System.out.println(" ok");
8599
new Test_Inner(8) {}.new Test_Abstract_a().testing();
86100

101+
try {
102+
System.out.println(abs.getClass().getMethod("testing", new Class<?>[] {}).getName());
103+
} catch (NoSuchMethodException | SecurityException e) {
104+
// TODO Auto-generated catch block
105+
e.printStackTrace();
106+
}
107+
87108

88109
System.out.println("Test_Inner OK");
89110
}

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// Google closure compiler cannot handle Clazz.new or Clazz.super
99

10+
// BH 2022.09.08 Fix new Test_Inner().getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName()
1011
// BH 2022.04.19 TypeError and ResourceError gain printStackTrace$() methods
1112
// BH 2022.03.19 String.valueOf(Double) does not add ".0"
1213
// BH 2022.01.17 fixes interface default method referencing own static fields
@@ -1199,7 +1200,7 @@ var shiftArray = function(a, i0, k) {
11991200

12001201
var getParamCode = Clazz._getParamCode = function(cl) {
12011202
cl.$clazz$ && (cl = cl.$clazz$);
1202-
return cl.__PARAMCODE || (cl.__PARAMCODE = stripJavaLang(cl.__CLASS_NAME$__ || cl.__CLASS_NAME__).replace(/\./g, '_'));
1203+
return cl.__PARAMCODE || (cl.__PARAMCODE = stripJavaLang(cl.__CLASS_NAME__).replace(/\./g, '_'));
12031204
}
12041205

12051206
var newTypedA = function(baseClass, args, nBits, ndims, isClone) {

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14043,6 +14043,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1404314043

1404414044
// Google closure compiler cannot handle Clazz.new or Clazz.super
1404514045

14046+
// BH 2022.09.08 Fix new Test_Inner().getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName()
1404614047
// BH 2022.04.19 TypeError and ResourceError gain printStackTrace$() methods
1404714048
// BH 2022.03.19 String.valueOf(Double) does not add ".0"
1404814049
// BH 2022.01.17 fixes interface default method referencing own static fields
@@ -15235,7 +15236,7 @@ var shiftArray = function(a, i0, k) {
1523515236

1523615237
var getParamCode = Clazz._getParamCode = function(cl) {
1523715238
cl.$clazz$ && (cl = cl.$clazz$);
15238-
return cl.__PARAMCODE || (cl.__PARAMCODE = stripJavaLang(cl.__CLASS_NAME$__ || cl.__CLASS_NAME__).replace(/\./g, '_'));
15239+
return cl.__PARAMCODE || (cl.__PARAMCODE = stripJavaLang(cl.__CLASS_NAME__).replace(/\./g, '_'));
1523915240
}
1524015241

1524115242
var newTypedA = function(baseClass, args, nBits, ndims, isClone) {

0 commit comments

Comments
 (0)