j2objc: j2objc cannot compile code that can be compiled with Java 8
I found this code pattern two times in RxJava library. It compiles and works in Java, but cannot be compiled/translated with j2objc.
public class Hello
{
public static class Bar
{
}
public static class Foo<T>
{
}
public static void main(String[] args)
{
Foo<? extends Bar> first = null;
Foo second = null;
Foo<Bar> result = Hello.create1(first, second); // j2obc Compilation fails here
}
private static <T> Foo<T> create1(Foo<T> sourceA, Foo<T> sourceB)
{
return null;
}
}
j2objc fails:
$ j2objc Hello.java error: Hello.java:15: Type mismatch: cannot convert from Hello.Foo<capture#1-of ? extends Hello.Bar> to Hello.Foo<Hello.Bar>
References to RxJava sources that fail:
- https://github.com/ReactiveX/RxJava/blob/2.x/src/main/java/io/reactivex/internal/operators/flowable/FlowableReplay.java#L131
FlowableReplay.java:131: error: Type mismatch: cannot convert from ConnectableFlowable<capture#22-of ? extends T> to ConnectableFlowable<T>
- https://github.com/ReactiveX/RxJava/blob/2.x/src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java#L126
ObservableReplay.java:126: error: Type mismatch: cannot convert from ConnectableObservable<capture#19-of ? extends T> to ConnectableObservable<T>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 22
“Argument list too long:” both j2objc and javac support an @<file> flag – just put all the flags and file names in a text file, and specify it with an @ in front of its path.
On Sun, Jan 15, 2017 at 11:19 AM Igor Zubchenok notifications@github.com wrote:
I just verified that both your test class and the RxJava project build with the javac front-end. To try this, pull or create your j2objc project clone to get the latest source, run “make -j4 dist” in the top-level directory, then run j2objc with the -Xuse-javac flag or the J2OBJC_FRONT_END=JAVAC environment variable. I did the latter, cloned the RxJava and reactive-streams-jvm projects, then ran the following build command in the RxJava top directory:
$ j2objc -l -d /tmp/reactive -sourcepath src/main/java:…/reactive-streams-jvm/api/src/main/java \ `find src/main/java …/reactive-streams-jvm/api/src/main/java -name *.java
We’ll close this issue when the javac front-end becomes the default.
I had seen Tom’s message that javac front-end will be in a month later. It was on Dec 13. Do you have any update on the date? I’ll be happy to run javac tests on my projects.