New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
j2objc cannot compile code that can be compiled with Java 8 #825
Comments
Any ideas how to fix it without modifications to RxJava? |
There's a good chance these errors will be fixed when we switch our parser front-end from Eclipse JDT to Javac. This is coming soon. |
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. |
Has it been a month? I realize the time zone in Belarus is ahead of
California's, but by a whole week? ;-)
The j2objc distribution now builds and passes its tests, and we're now
verifying that all internal clients build and test successfully. We've
pushed out all of our changes, so you can try the new front-end by running
"export J2OBJC_FRONT_END=JAVAC" in your bash shell (or set that environment
variable however you usually do). If that's inconvenient, edit Options.java
to change the JDT default front-end
<https://github.com/google/j2objc/blob/master/translator/src/main/java/com/google/devtools/j2objc/Options.java#L183>
to JAVAC. Generated files are (or should be) essentially the same, though
diff will show some comment differences. Please let us know what your
testing finds.
…On Fri, Jan 6, 2017 at 10:14 AM Igor Zubchenok ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#825 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC2kr6xNqWWlkN7c4JgzA0e1oPbdd9uBks5rPoShgaJpZM4Lc58T>
.
|
$ export J2OBJC_FRONT_END=JAVAC Seems v1.2 is not compatible with JAVAC yet. So I have to pull and build, I will do it and update you soon. |
My test file has been successfully compiled with JAVAC. |
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 \ We'll close this issue when the javac front-end becomes the default. |
After a busy start of the week, I've finally done tests. There were too many differences if I compare the latest 1.2 release with the latest j2objc version. So I first translated all code with the latest j2objc version and Eclipse JDT, and then started comparison with javac. My findings:
... to be continued :) Summary: the real problems are points 3 & 9. |
UPDATE: Now I have it all translated and I continue... :-) |
Regarding point 3: j2objc was designed to "work alike" javac as much as
possible, sharing the same flags -classpath, -sourcepath, -processorpath,
etc. For whatever reasons, we found that developers have an easier time
fixing source and class path issues if they start with a javac command, and
get that to compile successfully first. Our support goal has therefore been
to support project compilation issues when the same source can be compiled
using the same flags with javac.
My guess is that the original way j2objc was invoked to build your project
would not have worked if "javac" were substituted for "j2objc". Would you
please try building your project with javac, using the source and class
paths that caused point 3 to fail? If javac compiles with the original
paths but j2objc doesn't, then we have a front-end setup issue.
…On Fri, Jan 13, 2017 at 6:30 AM Igor Zubchenok ***@***.***> wrote:
UPDATE:
3. point 3 is solved: I had the base module source folders in the
CLASSPATH of the dependent module (I don't know exactly a reason but It
works with Eclipse JDT), so the issue had gone when I added the base module
sources to the SOURCEPATH of the dependent module. Please let me know if it
is not correct.
Now I have it all translated and I continue... :-)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#825 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC2krxhJxFSTsg0_4qnSTmbgtchPkuUTks5rR4qLgaJpZM4Lc58T>
.
|
The 0x10 modifier is FINAL. I ran j2objc over the test class below with both front-ends and compared their .h and .m files. The only difference was that the javac anonymous class is marked as FINAL, while the JDT one isn't (all other classes had identical declarations, implementations, and metadata). Since anonymous classes can't be extended, they are final whether their modifiers have the FINAL flag or not. Since anonymous class files are marked FINAL (use javap -v to see a class's flags), I think this is a harmless JDT bug and the javac front-end is correct. I'd like to therefore close point 2.
|
I can replicate point 9 (thanks for the example), and will fix it this weekend. Although we tested literally thousands of lines of code, this is probably the first double-brace initialization run through the new front-end. Even though that's considered an anti-pattern, we'll still fix it before switching the default. Even nasty code that compiled before needs to be supported! :-) |
A few my notes more:
|
Currently I'm facing the issue with my new Java code, it translates to objective c successfully, but I cannot compile it. Trying to get what is going on... Update 1: I have the same problem with j2objc 1.2 Update 2: Heh... got 'j2objc: Argument list too long' error. Is there a way to get recursively for translation all java files in source folder? Or specify list of java files in file? What is the best way to handle long list of files for translation? Update 3: Got my sources translated & compiled after modification of java code. Trying to get a sample for you... Update 4: To avoid 'Argument list too long' I tried to use relative path to java sources, but j2objc hangs and uses 100% in some infinite loop... This looks like an issue. Reverting back to absolute paths for now. |
The case can be simplified a little bit more and it will fail too. This is not exactly my case, but probably will help you: This translates, but cannot compile, I tried: Any ideas? |
"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 ***@***.***> wrote:
Reopened #825 <#825>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#825 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC2kr8Ltj19hc_jL39FK1D2IcrbjTkyzks5rSnFTgaJpZM4Lc58T>
.
|
So obviously there must be an issue that depends on number of files to translate. I believe now it will be easy to find a bug. :) |
We've disabled any batch maximum with the javac front-end (should be
submitted later today), since its performance is improved by compiling
everything at once, as you've noticed.
…On Mon, Jan 16, 2017 at 2:55 PM Igor Zubchenok ***@***.***> wrote:
1. [!!!] There is a huge performance impact when javac translation is
enabled. A little of statistics:
-
My test with Eclipse JDT front-end completes in 1:36 (with
--batch-translate-max=4, more than 4 has no more boost of performance, I
have 4 cores CPU at my build machine (2 core with hyperthreading))
-
With javac front-end translation is finished in 11 minutes (with
--batch-translate-max=4). However when I set value of --batch-translate-max
parameter equal to more than number of files to translate, like
--batch-translate-max=65536, I got performance boost and all my test
translates are completed just in 1:13.
So obviously there must be an issue that depends on number of files to
translate. I believe now it will be easy to find a bug. :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#825 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC2kr39nSMCk03oLbVb368vNGRRJ48BZks5rS_V3gaJpZM4Lc58T>
.
|
Regarding #11, this doesn't appear to be a regression between JDT and JAVAC front ends. If there are specific reserved words that we're not renaming, could you file a separate issue? |
|
--no-segmented-headers can result in compile errors if your Java code has class hierarchies that create circular include patterns. Try removing the flag if this is an issue for you. (or reorganize your Java code) Thanks very much for your help with testing our Javac front end! I'm going to close this issue because I believe we've resolved all the items. |
I found this code pattern two times in RxJava library. It compiles and works in Java, but cannot be compiled/translated with j2objc.
j2objc fails:
References to RxJava sources that fail:
FlowableReplay.java:131: error: Type mismatch: cannot convert from ConnectableFlowable<capture#22-of ? extends T> to ConnectableFlowable<T>
ObservableReplay.java:126: error: Type mismatch: cannot convert from ConnectableObservable<capture#19-of ? extends T> to ConnectableObservable<T>
The text was updated successfully, but these errors were encountered: