I'm trying to convert the Compression Scheme for Unicode implementation in Java to Objective-C using J2Objc. I have successfully downloaded and compiled J2Objc and run the command ./j2objec /SCSU/*.java
after making sure that the Java code compiles. Nevertheless, I'm getting a huge block of error mostly saying that some classes, variables and functions are undefined:
error: SCSU/Compress.java:41: SCSU cannot be resolved to a type
error: SCSU/Compress.java:63: The method getCurrentWindow() is undefined for the type Compress
error: SCSU/Compress.java:77: The method selectWindow(int) is undefined for the type Compress
error: SCSU/Compress.java:105: EndOfOutputException cannot be resolved to a type
error: SCSU/Compress.java:105: EndOfInputException cannot be resolved to a type
error: SCSU/Compress.java:105: IllegalInputException cannot be resolved to a type
error: SCSU/Compress.java:107: The method getCurrentWindow() is undefined for the type Compress
error: SCSU/Compress.java:126: IllegalInputException cannot be resolved to a type
error: SCSU/Compress.java:134: EndOfInputException cannot be resolved to a type
error: SCSU/Compress.java:143: IllegalInputException cannot be resolved to a type
error: SCSU/Compress.java:165: SQ0 cannot be resolved to a variable
error: SCSU/Compress.java:171: dynamicOffset cannot be resolved to a variable
error: SCSU/Compress.java:171: dynamicOffset cannot be resolved to a variable
error: SCSU/Compress.java:173: dynamicOffset cannot be resolved to a variable
error: SCSU/Compress.java:181: EndOfOutputException cannot be resolved to a type
error: SCSU/Compress.java:216: EndOfOutputException cannot be resolved to a type
error: SCSU/Compress.java:218: Debug cannot be resolved
error: SCSU/Compress.java:219: The method getCurrentWindow() is undefined for the type Compress
error: SCSU/Compress.java:224: EndOfOutputException cannot be resolved to a type
error: SCSU/Compress.java:228: SQ0 cannot be resolved to a variable
error: SCSU/Compress.java:231: dynamicOffset cannot be resolved to a variable
error: SCSU/Compress.java:231: dynamicOffset cannot be resolved to a variable
error: SCSU/Compress.java:233: dynamicOffset cannot be resolved to a variable
error: SCSU/Compress.java:238: staticOffset cannot be resolved to a variable
error: SCSU/Compress.java:238: staticOffset cannot be resolved to a variable
error: SCSU/Compress.java:240: staticOffset cannot be resolved to a variable
error: SCSU/Compress.java:245: Assert cannot be resolved to a type
error: SCSU/Compress.java:249: Debug cannot be resolved
error: SCSU/Compress.java:266: EndOfOutputException cannot be resolved to a type
error: SCSU/Compress.java:279: The method isCompressible(char) is undefined for the type Compress
And the log goes on... Why am I getting such errors and what should I do to resolve them?
You need to specify the directory where the sources are in the -sourcepath (j2objc uses the Eclipse compiler as its front-end, which is where this requirement comes from). I copied those source files to ~/Downloads/unicode, and used this command:
$ j2objc -d build -sourcepath ~/Downloads/unicode ~/Downloads/unicode/*.java
translating /Users/tball/Downloads/unicode/Assert.java
translating /Users/tball/Downloads/unicode/Compress.java
translating /Users/tball/Downloads/unicode/CompressMain.java
translating /Users/tball/Downloads/unicode/Debug.java
translating /Users/tball/Downloads/unicode/Display.java
translating /Users/tball/Downloads/unicode/EndOfInputException.java
translating /Users/tball/Downloads/unicode/EndOfOutputException.java
translating /Users/tball/Downloads/unicode/Expand.java
translating /Users/tball/Downloads/unicode/IllegalInputException.java
error: /Users/tball/Downloads/unicode/SCSU.java:241: The method reset in type SCSU can only set one of public / protected / private
That's a weird error at the end, but looking at the source found it's indeed illegal Java:
SCSU.java:241:
protected public void reset()
{
...
Fix that (remove either modifier), and you should be good to go.