Skip to content

Conversation

@BobHanson
Copy link
Owner

This update completely rewrites the way method signatures work in terms of generics. "$TK$TV" signatures are gone; $O$O and other proper type "erasure" is now working. This aligns all method names in SwingJS with those in Java .class files and removes any dependency on the specific choice of name for type variables (K, V, E, etc.).

Related to this fix is a rewrite of how synthetic methods are created for subclasses of generic classes and (especially) generic interfaces. Specifically, the unsolved issue with the interface java.util.Spliterator$OfInt in relation to java.util.Splterators.emptyIntSpliterator() is now fixed.

For the record, synthetic bridge methods needed to tie realized subtypes of generic classes are handled simply by aliasing method names in Clazz.newMeth() using an array instead of a simple name:

Clazz.newMeth(C$, ['put$S$O','put$O$O']...)

while synthetic methods for generic interfaces are handled by adding the aliases to the C$.$defaults$ function, as in java.util.Spliterator$OfInt:

C$.prototype['tryAdvance$java_util_function_IntConsumer']=C$.prototype['tryAdvance$O'];

(Interestingly, there are only two places in java.* where this is necessary -- java.util.Spliterator and java.nio.Path.)

Finally, synthetic access methods in Java for methods and final or effectively final variables in subclasses are handled on the fly by passing references to the proper class and field through an array. Java's access method:

static synthetic int access$0(int arg0, int arg1);
0 iload_0 [arg0]
1 iload_1 [arg1]
2 invokestatic java.util.IdentityHashMap.nextKeyIndex(int, int) : int [131]
5 ireturn

is not necessary (Was it in Java??) because we can use P$.IdentityHashMap.hash$O$I directly.

//BH 2020.01.08 -- 3.2.7-v1 sets generic references to their erasures;
adds implicit synthetic default methods to interfaces
missing "!" in swingjs.a2s.List item event check for
JList.isValueAdjusting()
@BobHanson BobHanson merged commit 80b1cc2 into master Jan 9, 2020
BobHanson added a commit that referenced this pull request Jan 25, 2020
Byte.parseByte; Foo a = null; b = a.staticCall()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants