A Java to iOS Objective-C translation tool and runtime.

Related tags

Miscellaneous j2objc
Overview

J2ObjC: Java to Objective-C Translator and Runtime

Project site: https://j2objc.org
J2ObjC blog: https://j2objc.blogspot.com
Questions and discussion: https://groups.google.com/group/j2objc-discuss

What J2ObjC Is

J2ObjC is an open-source command-line tool from Google that translates Java source code to Objective-C for the iOS (iPhone/iPad) platform. This tool enables Java source to be part of an iOS application's build, as no editing of the generated files is necessary. The goal is to write an app's non-UI code (such as application logic and data models) in Java, which is then shared by web apps (using GWT), Android apps, and iOS apps.

J2ObjC supports most Java language and runtime features required by client-side application developers, including exceptions, inner and anonymous classes, generic types, threads and reflection. JUnit test translation and execution is also supported.

J2ObjC is currently beta quality. Several Google projects rely on it, but when new projects first start working with it, they usually find new bugs to be fixed. If you run into issues with your project, please report them!

What J2ObjC isn't

J2ObjC does not provide any sort of platform-independent UI toolkit, nor are there any plans to do so in the future. We believe that iOS UI code needs to be written in Objective-C, Objective-C++ or Swift using Apple's iOS SDK (Android UIs using Android's API, web app UIs using GWT, etc.).

J2ObjC cannot convert Android binary applications. Developers must have source code for their Android app, which they either own or are licensed to use.

Requirements

License

This library is distributed under the Apache 2.0 license found in the LICENSE file. The protocol buffers library is distributed under the same BSD license as Google's protocol buffers. See its README and LICENSE.

Running on GNU/Linux

To build and run on GNU/Linux, install the Darling project, then following its Compile and Run a Program example. Please note that j2objc is only supported on iOS/macOS.

Comments
  • Add support for SQLite3 wrapper library.

    Add support for SQLite3 wrapper library.

    This is Issue 325 moved from a Google Code project. Added on 2014-02-02T05:21:12.000Z by [email protected]. Please review that bug for more context and additional comments, but update this bug.

    Original labels: Type-Enhancement, Priority-Medium

    opened by kstanger 35
  • Implementing SSLSocket and SSLSocketFactory

    Implementing SSLSocket and SSLSocketFactory

    I'm trying to implement an SSLSocketFactory to use within a j2objc project. I decided to use the Secure Transport API. In theory, it seems like the API provides exactly what I was looking for: It offers a TLS layer that, by means of callbacks, can be used with any lower layer channel. I don't need any of the customisability, I just want to be able to secure a Socket over TLS/SSL to connect to an HTTPS server for TCP-level communication.

    I created a WrappedSSLSocket class in Java, that just extends from the SSLSocket class and forwards all method calls to an underlying Socket.

    WrappedSSLSocket.java

    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.SocketAddress;
    import java.net.SocketException;
    import java.nio.channels.SocketChannel;
    
    import javax.net.ssl.HandshakeCompletedListener;
    import javax.net.ssl.SSLSession;
    import javax.net.ssl.SSLSocket;
    
    public class WrappedSSLSocket extends SSLSocket {
        protected Socket underlyingSocket;
    
        public WrappedSSLSocket(Socket underlying){
            this.underlyingSocket = underlying;
        }
    
        public Socket getUnderlyingSocket(){
            return underlyingSocket;
        }
    
        public void connect(SocketAddress endpoint) throws IOException {
            throw new RuntimeException("Stub!");
        }
    
        public void connect(SocketAddress endpoint, int timeout) throws IOException {
            underlyingSocket.connect(endpoint, timeout);
        }
    
        public void bind(SocketAddress bindpoint) throws IOException {
            underlyingSocket.bind(bindpoint);
        }
    
        public InetAddress getInetAddress() {
            return underlyingSocket.getInetAddress();
        }
    
        public InetAddress getLocalAddress() {
            return underlyingSocket.getLocalAddress();
        }
    
        public int getPort() {
            return underlyingSocket.getPort();
        }
    
        public int getLocalPort() {
            return underlyingSocket.getLocalPort();
        }
    
        public SocketAddress getRemoteSocketAddress() {
            return underlyingSocket.getRemoteSocketAddress();
        }
    
        public SocketAddress getLocalSocketAddress() {
            return underlyingSocket.getLocalSocketAddress();
        }
    
        public SocketChannel getChannel() {
            return underlyingSocket.getChannel();
        }
    
        public InputStream getInputStream() throws IOException {
            return underlyingSocket.getInputStream();
        }
    
        public OutputStream getOutputStream() throws IOException {
            return underlyingSocket.getOutputStream();
        }
    
        public void setTcpNoDelay(boolean on) throws SocketException {
            underlyingSocket.setTcpNoDelay(on);
        }
    
        public boolean getTcpNoDelay() throws SocketException {
            return underlyingSocket.getTcpNoDelay();
        }
    
        public void setSoLinger(boolean on, int linger) throws SocketException {
            underlyingSocket.setSoLinger(on, linger);
        }
    
        public int getSoLinger() throws SocketException {
            return underlyingSocket.getSoLinger();
        }
    
        public void sendUrgentData(int data) throws IOException {
            underlyingSocket.sendUrgentData(data);
        }
    
        public void setOOBInline(boolean on) throws SocketException {
            underlyingSocket.setOOBInline(on);
        }
    
        public boolean getOOBInline() throws SocketException {
            return underlyingSocket.getOOBInline();
        }
    
        public synchronized void setSoTimeout(int timeout) throws SocketException {
            underlyingSocket.setSoTimeout(timeout);
        }
    
        public synchronized int getSoTimeout() throws SocketException {
            return underlyingSocket.getSoTimeout();
        }
    
        public synchronized void setSendBufferSize(int size) throws SocketException {
            underlyingSocket.setSendBufferSize(size);
        }
    
        public synchronized int getSendBufferSize() throws SocketException {
            return underlyingSocket.getSendBufferSize();
        }
    
        public synchronized void setReceiveBufferSize(int size) throws SocketException {
            underlyingSocket.setSendBufferSize(size);
        }
    
        public synchronized int getReceiveBufferSize() throws SocketException {
            return underlyingSocket.getReceiveBufferSize();
        }
    
        public void setKeepAlive(boolean on) throws SocketException {
            underlyingSocket.setKeepAlive(on);
        }
    
        public boolean getKeepAlive() throws SocketException {
            return underlyingSocket.getKeepAlive();
        }
    
        public void setTrafficClass(int tc) throws SocketException {
            underlyingSocket.setTrafficClass(tc);
        }
    
        public int getTrafficClass() throws SocketException {
            return underlyingSocket.getTrafficClass();
        }
    
        public void setReuseAddress(boolean on) throws SocketException {
            underlyingSocket.setReuseAddress(on);
        }
    
        public boolean getReuseAddress() throws SocketException {
            return underlyingSocket.getReuseAddress();
        }
    
        public synchronized void close() throws IOException {
            underlyingSocket.close();
        }
    
        public void shutdownInput() throws IOException {
            underlyingSocket.shutdownInput();
        }
    
        public void shutdownOutput() throws IOException {
            underlyingSocket.shutdownOutput();
        }
    
        public String toString() {
            return "WrappedSocket (" + underlyingSocket.toString() + ")";
        }
    
        public boolean isConnected() {
            return underlyingSocket.isConnected();
        }
    
        public boolean isBound() {
            return underlyingSocket.isBound();
        }
    
        public boolean isClosed() {
            return underlyingSocket.isClosed();
        }
    
        public boolean isInputShutdown() {
            return underlyingSocket.isInputShutdown();
        }
    
        public boolean isOutputShutdown() {
            return underlyingSocket.isOutputShutdown();
        }
    
        public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
            underlyingSocket.setPerformancePreferences(connectionTime, latency, bandwidth);
        }
    
        /* SSLSocket implementation */
    
        @Override
        public String[] getSupportedCipherSuites() {
            // Not implemented
            return new String[0];
        }
    
        @Override
        public String[] getEnabledCipherSuites() {
            // Not implemented
            return new String[0];
        }
    
        @Override
        public void setEnabledCipherSuites(String[] strings) {
            // Not implemented
        }
    
        @Override
        public String[] getSupportedProtocols() {
            // Not implemented
            return new String[0];
        }
    
        @Override
        public String[] getEnabledProtocols() {
            // Not implemented
            return new String[0];
        }
    
        @Override
        public void setEnabledProtocols(String[] strings) {
            // Not implemented
        }
    
        @Override
        public SSLSession getSession() {
            // Not implemented
            return null;
        }
    
        @Override
        public void addHandshakeCompletedListener(HandshakeCompletedListener handshakeCompletedListener) {
            // Not implemented
        }
    
        @Override
        public void removeHandshakeCompletedListener(HandshakeCompletedListener handshakeCompletedListener) {
            // Not implemented
        }
    
        @Override
        public void startHandshake() throws IOException {
    
        }
    
        @Override
        public void setUseClientMode(boolean b) {
            // Not implemented
        }
    
        @Override
        public boolean getUseClientMode() {
            return true;
        }
    
        @Override
        public void setNeedClientAuth(boolean b) {
            // Not implemented
        }
    
        @Override
        public boolean getNeedClientAuth() {
            // Not implemented
            return false;
        }
    
        @Override
        public void setWantClientAuth(boolean b) {
            // Not implemented
        }
    
        @Override
        public boolean getWantClientAuth() {
            // Not implemented
            return false;
        }
    
        @Override
        public void setEnableSessionCreation(boolean b) {
            // Not implemented
        }
    
        @Override
        public boolean getEnableSessionCreation() {
            // Not implemented
            return false;
        }
    
    

    I then created a Swift class that extends from the j2objc-translated WrappedSSLSocket class. There, I create an SSLContext and set up its IO callbacks to read and write via the underlying Socket. From the doHandshake method, I call SSLHandshake.

    iOSSSLSocketFactory.swift

    import Foundation
    import Security
    
    class iOSSSLInputStream : JavaIoInputStream {
      unowned let sslSocket : iOSSSLSocket
      
      init(sslSocket : iOSSSLSocket) {
        self.sslSocket = sslSocket
        super.init()
      }
      
      override func read(with b: IOSByteArray!, with off: jint, with len: jint) -> jint {
        if (sslSocket.isClosed() || (sslSocket.underlyingSocket?.isClosed())!){
          ObjC.throwException(JavaIoIOException(nsString: "Cannot read from closed socket"))
        }
        
        if (sslSocket.isInputShutdown() || (sslSocket.underlyingSocket?.isInputShutdown())!){
          ObjC.throwException(JavaIoIOException(nsString: "Cannot read from shutdown socket"))
        }
        
        let unsafePointer = UnsafeMutableRawPointer(b.byteRef(at: UInt(off)))
        var actuallyRead : Int = 0
        let status = SSLRead(sslSocket.getSSLContext()!, unsafePointer!, Int(len), &actuallyRead)
        if (status == errSecSuccess){
          return jint(actuallyRead)
        } else {
          ObjC.throwException(JavaIoIOException(nsString: "Error reading from SSL: " + String(status)))
        }
        return jint(actuallyRead)
      }
      
      override func read(with b: IOSByteArray!) -> jint {
        return read(with: b, with: 0, with: b.length())
      }
      
      override func read() -> jint {
        let buffer = IOSByteArray.newArray(withLength: 1)
        let actuallyRead = read(with: buffer)
        if (actuallyRead == 1) {
          let resultByte : jbyte = (buffer?.byte(at: 0))!
          return jint(resultByte)
        } else {
          return actuallyRead
        }
      }
      
      override func close() {
        sslSocket.close()
      }
      
      override func available() -> jint {
        // Not supported
        return 0;
      }
      
      override func mark(with readlimit: jint) {
        // Not supported
      }
      
      override func markSupported() -> jboolean {
        return false
      }
      
      override func reset() {
        // Not supported
      }
      
      override func skip(withLong n: jlong) -> jlong {
        // Not supported
        return 0
      }
    }
    
    class iOSSSLOutputStream : JavaIoOutputStream {
      unowned let sslSocket : iOSSSLSocket
      
      init(sslSocket : iOSSSLSocket) {
        self.sslSocket = sslSocket
        super.init()
      }
      
      override func write(with b: IOSByteArray!, with off: jint, with len: jint) {
        if (sslSocket.isClosed() || (sslSocket.underlyingSocket?.isClosed())!){
          ObjC.throwException(JavaIoIOException(nsString: "Cannot write to closed socket"))
        }
        
        if (sslSocket.isOutputShutdown() || (sslSocket.underlyingSocket?.isOutputShutdown())!){
          ObjC.throwException(JavaIoIOException(nsString: "Cannot write to shutdown socket"))
        }
        
        var unsafePointer = UnsafeMutableRawPointer(b.byteRef(at: UInt(off)))
        var actuallyWrote : Int = 0
        var remaining : Int = Int(len);
        
        while remaining > 0 {
          let status = SSLWrite(sslSocket.getSSLContext()!, unsafePointer, remaining, &actuallyWrote)
          if (status == noErr){
            unsafePointer = unsafePointer?.advanced(by: actuallyWrote)
            remaining -= actuallyWrote
          } else {
            ObjC.throwException(JavaIoIOException(nsString: "Error writing to SSL: " + String(status)))
          }
        }
      }
      
      override func write(with b: IOSByteArray!) {
        write(with: b, with: 0, with: b.length())
      }
      
      override func write(with b: jint) {
        let buffer = IOSByteArray.newArray(withLength: 1)
        buffer?.replaceByte(at: 0, withByte: jbyte(b))
        write(with: buffer)
      }
      
      override func close() {
        sslSocket.close()
      }
      
      override func flush() {
        sslSocket.getUnderlyingSocket().getOutputStream().flush()
      }
    }
    
    class iOSSSLSocket : WrappedSSLSocket{
      var sslContext : SSLContext?
      var inputStream : iOSSSLInputStream?
      var outputStream : iOSSSLOutputStream?
      var underlyingSocket : JavaNetSocket?
      
      init(underlyingSocket: JavaNetSocket, hostName: String) {
        self.underlyingSocket = underlyingSocket
        self.sslContext = SSLCreateContext(nil, SSLProtocolSide.clientSide, SSLConnectionType.streamType)
      
        super.init(javaNetSocket: underlyingSocket)
        
        self.inputStream = iOSSSLInputStream(sslSocket: self)
        self.outputStream = iOSSSLOutputStream(sslSocket: self)
      
        var status = noErr
        status = SSLSetIOFuncs(sslContext!, sslReadCallback, sslWriteCallback)
        if (status != noErr) {
          ObjC.throwException(JavaIoIOException(nsString: "Error setting IO functions: " + String(status)))
        }
        
        let ref : SSLConnectionRef = UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque())
        status = SSLSetConnection(sslContext!, ref)
        if (status != noErr) {
          ObjC.throwException(JavaIoIOException(nsString: "Error setting connection data: " + String(status)))
        }
        
        status = SSLSetPeerDomainName(sslContext!, hostName, hostName.lengthOfBytes(using: String.Encoding.utf8))
        if (status != noErr) {
          ObjC.throwException(JavaIoIOException(nsString: "Error setting domain name: " + String(status)))
        }
      }
      
      override func startHandshake() {
        let status = SSLHandshake(sslContext!)
        if (status != noErr) {
          let cfDescription : CFString = SecCopyErrorMessageString(status, nil)!
          let description = cfDescription as String
          ObjC.throwException(JavaIoIOException(nsString: "Handshake error: " + String(status) + " - " + description))
        }
      }
      
      func getSSLContext() -> SSLContext?{
        return sslContext
      }
      
      var sslReadCallback : @convention(c) (SSLConnectionRef, UnsafeMutableRawPointer, UnsafeMutablePointer<Int>) -> OSStatus =
      {(connection: SSLConnectionRef, data: UnsafeMutableRawPointer, size: UnsafeMutablePointer<Int>) -> OSStatus in
        
        let socket = Unmanaged<iOSSSLSocket>.fromOpaque(connection).takeUnretainedValue()
        
        let javaByteBuffer = IOSByteArray.newArray(withLength: UInt(size.pointee))
        var result = noErr
        
        do {
          try ObjC.catchException {
            let actuallyRead = socket.getUnderlyingSocket().getInputStream().read(with: javaByteBuffer)
            if (actuallyRead >= 0) {
              let jbytePointer = data.bindMemory(to: jbyte.self, capacity: size.pointee)
              javaByteBuffer?.getBytes(jbytePointer, length:UInt(actuallyRead))
              size.pointee = Int(actuallyRead)
            } else {
              result = errSSLBadCert
            }
          }
        } catch {
          result = errSSLClosedAbort
        }
        return result
      }
      
      var sslWriteCallback : @convention(c) (SSLConnectionRef, UnsafeRawPointer, UnsafeMutablePointer<Int>) -> OSStatus =
      {(connection: SSLConnectionRef, data: UnsafeRawPointer, size: UnsafeMutablePointer<Int>) -> OSStatus in
    
        let socket = Unmanaged<iOSSSLSocket>.fromOpaque(connection).takeUnretainedValue()
    
        let jbytePointer = data.bindMemory(to: jbyte.self, capacity: size.pointee)
        let javaByteBuffer = IOSByteArray.newArray(withBytes:jbytePointer, count: UInt(size.pointee))
        
        do {
          try ObjC.catchException {
            socket.getUnderlyingSocket().getOutputStream().write(with: javaByteBuffer)
            socket.getUnderlyingSocket().getOutputStream().flush()
          }
        } catch {
          return errSSLClosedAbort
        }
        return noErr
      }
      
      override func close() {
        if (isClosed()) {
          ObjC.throwException(JavaIoIOException(nsString: "Already closed"))
        }
        
        SSLClose(sslContext!)
        
        underlyingSocket?.close()
      }
      
      override func getInputStream() -> JavaIoInputStream! {
        return inputStream
      }
      
      override func getOutputStream() -> JavaIoOutputStream! {
        return outputStream
      }
    }
    
    class iOSSSLSocketFactory : JavaxNetSslSSLSocketFactory{
      override func createSocket(with s: JavaNetSocket!, with host: String!, with port: jint, withBoolean autoClose: jboolean) -> JavaNetSocket! {
        return iOSSSLSocket(underlyingSocket: s, hostName: host)
      }
      
      override func createSocket() -> JavaNetSocket! {
        // Not implemented
        return nil
      }
      
      override func createSocket(with host: String!, with port: jint) -> JavaNetSocket! {
        // Not implemented
        return nil
      }
      
      override func getSupportedCipherSuites() -> IOSObjectArray! {
        // Not implemented
        return nil
      }
      
      override func getDefaultCipherSuites() -> IOSObjectArray! {
        // Not implemented
        return nil
      }
    }
    

    Now, in theory, I guess this should work. Unfortunately, it only works sporadically: The handshake sometimes succeeds, but more often, SSLHandshake returns an error:

    -50 - One or more parameters passed to a function were not valid.

    Interestingly, the code seems more likely to succeed if I log from within the callback functions or use breakpoints to stop execution, so my guess is there are some race conditions that I didn't think of. Is there something in the j2objc code that could cause these issues? Is there anything with the handling of the underlying Socket in the callbacks that I've overseen?

    For testing the code, I use this simple test:

    SSLSocketTest.java

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.InetSocketAddress;
    import java.net.Socket;
    
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    
    public class SSLSocketTest {
        private SSLSocketFactory mFactory;
        private String mHost;
        private int mPort;
    
        // For example: www.google.com, 443
        public SSLSocketTest(SSLSocketFactory factory, String host, int port){
            mFactory = factory;
            mHost = host;
            mPort = port;
        }
    
        public void run(){
            try {
                Socket socket = new Socket();
                socket.connect(new InetSocketAddress(mHost, mPort));
                SSLSocket sslSocket = (SSLSocket) mFactory.createSocket(socket, mHost, mPort, true);
                sslSocket.startHandshake();
    
                String request = "GET / HTTP/1.1\nHost:" + mHost + "\n\n";
                sslSocket.getOutputStream().write(request.getBytes());
                sslSocket.getOutputStream().flush();
    
                StringBuilder response = new StringBuilder();
                BufferedReader br = new BufferedReader(new InputStreamReader(sslSocket.getInputStream()));
                response.append(br.readLine());
                br.close();
            } catch (Exception e) {
                // Removed custom logging
            }
        }
    }
    
    

    For completeness:

    ObjC.h

    #import <Foundation/Foundation.h>
    
    @interface ObjC : NSObject
    
    + (BOOL)catchException:(void(^)())tryBlock error:(__autoreleasing NSError **)error;
    + (void)throwException:(id)exception;
    
    @end
    
    

    ObjC.m

    #import "ObjC.h"
    
    @implementation ObjC
    
    + (BOOL)catchException:(void(^)())tryBlock error:(__autoreleasing NSError **)error {
      @try {
        tryBlock();
        return YES;
      }
      @catch (NSException *exception) {
        *error = [[NSError alloc] initWithDomain:exception.name code:0 userInfo:exception.userInfo];
        return NO;
      }
    }
    
    + (void)throwException:(id)exception{
      @throw exception;
    }
    
    @end
    

    Also, I'm wondering if an SSLSocketFactory like this could be added to j2objc? It seems like most of Java's SSLSocket functionality can be implemented with the Secure Transport API. Obviously that leaves things like certificate parsing to iOS (without possibility for any Java-side interventions), but I would think that's fine for most applications.

    opened by FD- 34
  • Mac Catalyst Support

    Mac Catalyst Support

    I get the following error when I try to compile iOS project to work with Mac Catalyst (for macOS Catalina):

    .../lib/libjre_emul.a(ErrnoException.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '/Users/admin/Documents/Workspaces/j2objc/lib/libjre_emul.a' for architecture x86_64

    opened by kangert 30
  • ClassCastException in iOS11

    ClassCastException in iOS11

    Hi, I will use fake code to describe the problem.

    I use j2objc in a framework【FrameworkA】. a protocol【ProcotolA】(translate from java interface) and I have a class like this

    class ClassA : NSObject, ProtocolA {
        //ProtocolA implemention code.
    }
    

    in java code have some code like this

    //obj is ClassA instance
    public void method(Object obj) {
        otherMethod((ProtocolA) obj);
    }
    

    when I use frameworkA in my project it says

    java.lang.ClassCastException: Cannot cast object of type FrameworkA.ClassA to ProtocolA
    

    My j2objc version is 2.0.4. Swift version is 3.2. (use 3.1 before iOS11) But before iOS11 update it is ok, very weird. Can you give me some suggestions about this? Thank you very much.

    opened by HoneyLuka 27
  • j2objc cannot compile code that can be compiled with Java 8

    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:

    1. 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>
    2. 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>
    opened by zubchenok 22
  •  error: failed batch processing sources: Should produce more helpful error messages

    error: failed batch processing sources: Should produce more helpful error messages

    While translating the following:

     /Applications/J2Objc/j2objc-0.9.8b/j2objc -d /Users/mg/Downloads/Majestella/shared/build/j2objcSrcGen -sourcepath /Users/mg/Downloads/Majestella/shared/src/main/java:/Users/mg/Downloads/Majestella/shared/build/translationExtraction:/Users/mg/Downloads/Majestella/shared/build/source/apt:/Users/mg/Downloads/Majestella/shared/build/source/base:/Users/mg/Downloads/Majestella/shared/src/test/java -classpath /Users/mg/Downloads/Majestella/shared/lib/json-20140107.jar:/Users/mg/Downloads/Majestella/shared/lib/javax.inject-1.jar:/Users/mg/Downloads/Majestella/shared/lib/auto-factory-1.0-beta2.jar:/Users/mg/Downloads/Majestella/shared/lib/auto-service-1.0-rc2.jar:/Users/mg/Downloads/Majestella/shared/lib/javawriter-2.5.1.jar:/Users/mg/Downloads/Majestella/shared-prebuild/build/libs/shared-prebuild-1.0.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/j2objc_annotations.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/j2objc_guava.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/j2objc_junit.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/jre_emul.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/javax.inject-1.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/jsr305-3.0.0.jar:/Applications/J2Objc/j2objc-0.9.8b/lib/mockito-core-1.9.5.jar:/Users/mg/Downloads/Majestella/shared/build/classes --no-package-directories --prefixes prefixes.properties -use-arc --doc-comments --generate-deprecated /Users/mg/Downloads/Majestella/shared/build/source/apt/generated/BPlaceTokenRegistryImpl.java /Users/mg/Downloads/Majestella/shared/build/source/apt/generated/ProxyModule.java /Users/mg/Downloads/Majestella/shared/build/source/apt/majestella/core/app/serviceSelection/ServiceSelectionPresenterMyProxyImpl.java /Users/mg/Downloads/Majestella/shared/src/main/java/TestClass.java
    

    I get the following error:

      Working Dir:
      /Users/mg/Downloads/Majestella/shared
      Cause:
      org.gradle.process.internal.ExecException: Process 'command '/Applications/J2Objc/j2objc-0.9.8b/j2objc'' finished with non-zero exit value 1
      Standard Output:
    
      Error Output:
      1. ERROR: failed
      2. ERROR: failed
      3. ERROR: failed
      4. ERROR: failed
      5. ERROR: failed
      6. ERROR: failed
      7. ERROR: failed
      8. ERROR: failed
      9. ERROR: failed
      10. ERROR: failed
      11. ERROR: failed
      12. ERROR: failed
      12 problems (12 errors)
      error: failed batch processing sources
    
    cannot reproduce 
    opened by confile 19
  • Cookies are not set in default cookie handler during the redirection (HttpURLConnection in iOS)

    Cookies are not set in default cookie handler during the redirection (HttpURLConnection in iOS)

    Problem: In the iOS implementation of the HttpURLConnection class cookies are not set in default cookie handler during the redirection (in Android everything works fine).

    To test this problem here is a test service https://damp-dawn-68572.herokuapp.com with method "redirect". It sets cookie 'some_cookie=42' and redirects to method "getcook" which returns a list of cookies that came to it. Server Node.js source code:

    const express = require('express')
    express().get('/getcook', (req, res) => {
    	const cookie = req.headers.cookie || "";
    	return res.send('Request cookies: ' + cookie.split('; '));
    }).get('/redirect', (req, res) => {
    	res.cookie('some_cookie', 42);
    	return res.redirect('/getcook');
    }).listen(5000);
    

    Here is sample JAVA code to reproduce:

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.CookieHandler;
    import java.net.CookiePolicy;
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    class Main {
    
        public static void main(String[] args) {
            try {
                CookieHandler.setDefault(new java.net.CookieManager(null, CookiePolicy.ACCEPT_ALL));
                URL url = new URL("https://damp-dawn-68572.herokuapp.com/redirect");
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.connect();
                int code = connection.getResponseCode();
                BufferedReader br =	new BufferedReader(new InputStreamReader(connection.getInputStream()));
                StringBuilder sb = new StringBuilder();
                String output;
                while ((output = br.readLine()) != null) {
                    sb.append(output);
                }
                String body = sb.toString();
                System.out.print(code);
                System.out.print(body); //Here I expect to see string "Request cookies: some_cookie=42"
                connection.disconnect();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    And as result translated to iOS code is "Request cookies: " I think cookie are not set during any intermediate redirects in iOS implementation.

    Pending 
    opened by kluverua 17
  • The [IOSClass getDeclaredClasses] method fails when called on a class that has prefix applied

    The [IOSClass getDeclaredClasses] method fails when called on a class that has prefix applied

    Assume I have a Java class as follows:

    package com.mycompany.mysdk;
    
    public class SomeClass {
        public class Inner {
        }
    }
    

    If I translate this Java class to Objective-C without applying a prefix, then making the following call...

    IOSObjectArray *declaredClasses = [ComMycompanyMysdkSomeClass_class_() getDeclaredClasses];
    

    ... succeeds and I get a sensible array for declaredClasses.

    However, if I translate the Java class to Objective-C with a prefix applied (albeit an empty prefix), then making the following call...

    IOSObjectArray *declaredClasses = [SomeClass_class_() getDeclaredClasses];
    

    ... results in a JavaLangClassNotFoundException being thrown with this message: "com.mycompany.mysdk.SomeClass$Inner".

    opened by adil-hussain-84 16
  • jre_emul_dist Error 2:

    jre_emul_dist Error 2:

    Hi! I first started using j2objc (2.0.5), After running make dist in the directory /j2objc/ gives an error: " Building j2objc annotations mvn -q generate-resources dependency: sources building j2objc jar building jre_emul.jar building jre_emul-src.jar / bin / sh: line 0: [: / Users / XXXX / Documents / ?: binary operator expected / bin / sh: line 0: [: / Users / XXXX / Documents / ?: binary operator expected / bin / sh: line 0: [: / Users / XXXX / Documents / ?: binary operator expected / bin / sh: line 0: [: / Users / XXXX / Documents / ?: binary operator expected / bin / sh: line 0: [: / Users / XXXX / Documents / ?: binary operator expected / bin / sh: line 0: [: / Users / XXXX / Documents / ?: binary operator expected / bin / sh: ... / jre_emul / build_result / Classes / .translate_mark_jre_emul: No such file or directory .... " And there are about 30 such lines. How to fix? What is the reason?

    invalid 
    opened by NikolBoh 15
  • java.security.Signature.verify method call failing with EXC_BAD_ACCESS error

    java.security.Signature.verify method call failing with EXC_BAD_ACCESS error

    I'm using version 1.3.1 of the J2ObjC library. I'm attempting to verify a SHA256WithRSA signature with the java.security.Signature class as follows:

    BigInteger publicExponent = new BigInteger(PUBLIC_EXPONENT_BYTES);
    BigInteger modulus = new BigInteger(MODULUS_BYTES);
    
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    KeySpec keySpec = new RSAPublicKeySpec(modulus, publicExponent);
    PublicKey publicKey = keyFactory.generatePublic(keySpec);
    
    Signature signature = Signature.getInstance("SHA256WithRSA");
    signature.initVerify(publicKey);
    signature.update(dataBytes);
    
    boolean signatureValid = signature.verify(signatureBytes);
    

    I've verified the Java code and it runs okay. The translated code however falls over on the last line above with a EXC_BAD_ACCESS error. I have tried it both in the Simulator as well as on a real device.

    I'm guessing that the code should run okay since it has translated from Java to Objective-C without issues. Is this a bug in the J2ObjC library or should I refrain from doing SHA256WithRSA signature verification in the translated code?

    opened by adil-hussain-84 15
  • Access Enums in Swift more simple

    Access Enums in Swift more simple

    As I described here it is hard to access Java Enums from Swift. This can be done with:

    var r:BISBTestTypeEnum = BISBTestTypeEnum.values().objectAtIndex(BISBTestType.Type1.rawValue) as! BISBTestTypeEnum
    

    As you can see it is very long. It would be great if you could add one helper method to make such access more simple.

    If you would add a method like this (Swift):

        class func withValue(value: BISBTestType) -> BISBTestTypeEnum {
            return BISBTestTypeEnum.values().objectAtIndex(value.rawValue) as! BISBTestTypeEnum
        }
    

    in Objective-C I guess that is something like this:

    + (BISBTestTypeEnum *)valueOfWithNSString:(BISBTestType *)value {
      return [[BISBTestTypeEnum values] objectAtIndex:[value rawValue]];
    }
    

    you can access Enums as:

    var r = BISBTestTypeEnum.withValue(BISBTestType.Type1)
    
    opened by confile 15
  • No 2.x release available for j2objc-annotations on Maven central

    No 2.x release available for j2objc-annotations on Maven central

    The last release for j2objc-annotations is 1.3 on Maven central.

    2.x seems to be now main release that is regularly maintained, but no release is available for it on Maven central.

    1.3 is getting highlighted as EOL in the scanner, so will it be possible to release 2.x on Maven? We make use of Guava a lot and it has dependency on j2objc-annotations. They cannot upgrade because no new release is available on Maven central.

    opened by sandeepk-veritas 2
  • Upgrade J2Objc JRE emul to Android13 for javax.xml.*.

    Upgrade J2Objc JRE emul to Android13 for javax.xml.*.

    Upgrade J2Objc JRE emul to Android13 for javax.xml.*.

    See go/bb-j2objc-android13-jre-upgrade for more info.

    Tasks tracking sheet: https://docs.google.com/spreadsheets/d/1fDRe2Zn5ln2lEa7IdI7fpELtRIUOVc0yNjeYibzq48E/edit#gid=0

    kokoro:run 
    opened by copybara-service[bot] 0
  • Building fat file for libj2objc_main.a

    Building fat file for libj2objc_main.a

    Problem

    The dist/lib/macosx/libj2objc_main.a file that is produced by the jre_emul Makefile only supports the architecture of the machine used to build J2Objc. This causes a linking error when invoking j2objcc.sh on a machine with a different architecture.

    ld: warning: ignoring file /Users/example/j2objc/dist/lib/macosx/libj2objc_main.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
    

    I found that I could successfully run j2objcc after I manually compiled jre_emul/Classes/J2ObjCMain.m for x86 and arm64, combined the two libs into a fat file, and then moved the fat file to dist/lib/macosx/libj2objc_main.a.

    Given this, does it make sense to update the jre_emul Makefile to produce a fat file for libj2objc_main.a?

    Steps to Reproduce

    Build

    export J2OBJC_ARCHS="macosx macosx64"
    make dist
    

    Inspect Libraries

    $ find dist/lib/macosx -type f -exec lipo -info {} \;
    Architectures in the fat file: dist/lib/macosx/libjre_core.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjunit.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_net.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_time.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_icu.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_file.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_beans.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_concurrent.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_sql.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libmockito.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjsr305.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libxalan.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_security.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_zip.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_xml.a are: x86_64 arm64 
    Non-fat file: dist/lib/macosx/libj2objc_main.a is architecture: arm64
    Architectures in the fat file: dist/lib/macosx/libjre_util.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_ssl.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjavax_inject.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libguava.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libguavaandroid.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_io.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_channels.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libtruth.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjre_emul.a are: x86_64 arm64 
    Architectures in the fat file: dist/lib/macosx/libjson.a are: x86_64 arm64 
    
    opened by FrankManns 0
  • Abstract method that returns byte[] array translated with --objc-generics raises compile error

    Abstract method that returns byte[] array translated with --objc-generics raises compile error

    Hi,

    we have Java file with method:

    abstract byte[] readData();
    

    In .h is generated:

    - (IOSArray<JavaLangByte *> *)readData;
    

    It raises compile error: Declaration of JavaLangByte must be imported before required

    It looks like that generator counts with usage of IOSByteArray (it is defined by @class declaration in .h file). That is also type, that is used in generated .m file.

    opened by sarsonj 2
Releases(2.8)
  • 2.8(Apr 6, 2021)

    A new release of J2ObjC is available, 2.8. This is an update to 2.7 with bug fixes and the following changes:

    iOS Support

    • J2ObjC frameworks now support Apple Silicon (macOS ARM64).

    Translator

    • @Weak and @WeakOuter annotations are translated as zeroing weak references (requires -fobjc-arc or -fobjc-weak flag).
    • Retain/autoreleases parameters and local variables returned by lambdas and anonymous class methods.

    Libraries

    • Flogger call site injection implemented.
    • Guava updated to 30.1, added failureaccess-1.0.1.jar dependency.
    • JUnit updated to 4.13.
    • Protobuf runtime updated to optionally support ARC.
    • Protobuf enum constants no longer inlined, to support Swift importing.

    Notes

    • Starting with 2.7, the release distribution has been split into two zip files, with the frameworks directory in the j2objc-2.8-frameworks.zip file. This was necessary to work around GitHub release maximum sizes. Unzipping both zip files from the same directory creates the full distribution, and is only necessary if your iOS project uses J2ObjC frameworks.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.8-frameworks.zip(823.89 MB)
    j2objc-2.8.zip(1834.05 MB)
  • 2.7(Sep 18, 2020)

    A new release of J2ObjC is available, 2.7. This is an update to 2.6 with bug fixes and the following changes:

    JRE Runtime Emulation

    • Sources updated to Android 10, full Java 8 API.
    • New packages:
      • java.nio.file
      • java.nio.file.attribute
      • java.nio.file.spi
      • javax.sql

    Translator

    • New memory model annotations, to avoid dangling pointers in generated code:
      • ZeroingWeak: generates a __weak annotation with ARC, WeakReference<T> with reference-counting.
      • OnDealloc: annotates a method to be called from the dealloc Objective C method.

    Other

    • The release distribution has been split into two zip files, with the frameworks directory in the j2objc-2.7-frameworks.zip file. This was necessary to work around GitHub release maximum sizes. Unzipping both zip files from the same directory creates the full distribution, and is only necessary if your iOS project uses J2ObjC frameworks.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.7-frameworks.zip(807.85 MB)
    j2objc-2.7.zip(1809.43 MB)
  • 2.6(Apr 21, 2020)

    A new release of J2ObjC is available, 2.6. This is an update to 2.5 with bug fixes and the following changes:

    iOS 11.0 Support (Apple release notes)

    • Frameworks are now built as XCFramework bundles.
    • Hello and HelloSwift examples can now be built using Mac Catalyst.

    Translator

    Java Runtime Emulation

    • Android's nullability annotations for the JRE. This reduces optional types when transpiled code is imported into Swift.
    • Updated several packages to Android Pie.

    Other

    • Updated the protocol buffers dependency to 3.11.1.
    • Added Xalan's META-INF/services resources to its framework.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.6.zip(2023.30 MB)
  • 2.5(Jul 15, 2019)

    A new release of J2ObjC is available, 2.5. This is an update to 2.4 with bug fixes and the following changes:

    Translator

    • The flag -external-annotation-file allows to provide the most common J2ObjC annotations in a separate file. This feature is useful when you only need to add J2ObjC annotations to transpile an existing library (e.g. adding @WeakOuter to break retain cycles). We are using it to transpile our JRE: j2objc.jaif
    • The flag --reserved-names helps to extend the data already present in reserved_names.txt

    Java Runtime Emulation

    • java.text.BreakIterator was added. Keep in mind that it requires the jre_icu library which will impact the size of your application.
    • ICU resources were updated to version 60b.

    Other

    • Updated bundled Mockito to version 2.23.4.
    • Updated the protocol buffers dependency to 3.7.1.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.5.zip(1585.30 MB)
  • 2.4(Mar 15, 2019)

    A new release of J2ObjC is available, 2.4. This is an update to 2.3 with the following changes:

    Translator

    Experimental support of new Java language features:

    • Effectively final variables in try-with-resources.
    • Diamond Operator for Anonymous Inner Classes.
    • Private methods in interfaces.
    • Local-variable type inference.

    You can test this new functionality by running the translator with Java 11.

    JAVA_HOME=`/usr/libexec/java_home -v 11` path/to/j2objc path/to/java_file
    

    If you build your own distribution and want to support these features, please check scripts/build_distribution.sh for more details.

    Java Runtime Emulation

    • CompletableFuture was added.

    Other

    • Updated bundled Mockito to version 1.10.19.
    • Bundled @WeakOuter can be used also as a type annotation. This allows you to apply the annotation to anonymous classes.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.4.zip(1473.89 MB)
  • 2.3.1(Jan 11, 2019)

    A new release of J2ObjC is available, 2.3.1 (minor update to 2.3). Main changes:

    Java Runtime Emulation

    • Several libraries were updated to the Android Oreo version.

    Bug fixes

    • Issues: #1019, #1020, #1021.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.3.1.zip(1459.83 MB)
  • 2.3(Nov 27, 2018)

    A new release of J2ObjC is available, 2.3 (update to 2.2). Main changes:

    Java Runtime Emulation

    • Support for java.time package.
    • Subset of android.icu to support time zones (mainly to enable java.time).
    • SSL socket client implementation (thanks to @FD- for providing a reference implementation).

    Other

    • Added Android version of Guava library.
    • Removed obsolete 32-bit library architectures.
    • Added support for arm64_32 architecture in watchOS binaries (thanks to @gianlucabertani for the pull request).

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.3.zip(1456.48 MB)
  • 2.2(Sep 10, 2018)

    A new release of J2ObjC is available, 2.2. This is an update to 2.1.1 with bug fixes and the following changes:

    Translator

    • The file prefixes.properties no longer needs to be bundled with the app because reflection support for name mappings is automatically generated.
    • The flag --swift-friendly now generates class properties (instead of static accessor methods) for static variables and enum constants. If this change breaks your build, you can get the previous behavior by replacing --swift-friendly with --static-accessor-methods --nullability.
    • Making sure that --prefixes respects the definition order of package prefixes (Issue #995).
    • Support for nullability annotations declared as type annotations.

    Java Runtime Emulation

    • Added fallback Xalan properties (Issue #978).

    Other

    • Added IntelliJ project files.
    • Updated bundled Guava to version 25.1.
    • Added Swift sample project.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.2.zip(1245.66 MB)
  • 2.1.1(Apr 23, 2018)

  • 2.1(Sep 10, 2018)

    A new release of J2ObjC is available, 2.1. This is an update to 2.0.5 with several bug fixes and the following changes:

    Translator

    • The j2objc and cycle_finder tools now run using Java 9. Note: no Java 9 API have been added, since there aren't any Android equivalents.
    • Added option to generate outputs for all specified Java sources to a single .h/.m file pair.
    • Added support for AAR files on the classpath.

    Java Runtime Emulation

    • Added java.security digest stream classes.
    • New character encodings: GBK, GB18030, Big5-HK.
    • Removed okio from build, as it was no longer used.

    WatchOS Libraries

    There are now separate static libraries for watchOS in the distribution in lib/watchos. This avoids Xcode warnings including the equivalent architecture from the default iOS libraries, like is done for macOS (lib/macosx) and tvOS (lib/appletvos).

    Example Projects

    The example projects are now included in the distribution bundle. These include an iOS "hello world" app, macOS protocol buffer command-line examples, and a Contacts app.

    • The Contacts app demonstrates how to build a J2ObjC project with Bazel.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.1.zip(1095.04 MB)
  • 2.0.5(Oct 24, 2017)

    A new release of J2ObjC is available, 2.0.5. This is an update to 2.0.4.1 with several bug fixes and the following changes:

    Swift Support:

    • Fixed generation of JRE.framework/JRE.h to only include public header files.
    • Updated function prototypes to avoid strict-prototype warnings from Xcode 9.
    • Annotates copyWithZone: argument as nullable.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.0.5.zip(1076.98 MB)
  • 2.0.4.1(Oct 3, 2017)

  • 2.0.4(Sep 28, 2017)

    A new release of J2ObjC is available, 2.0.4. This is an update to 2.0.3 with several bug fixes and the following changes:

    J2ObjC translator:

    • Eclipse JDT dependencies are removed.
    • Android Library (*.aar) files are now supported in classpath arguments.
    • Runs when Java 9 JDK is system default.
      • NOTE: Java 8 still needs to be installed (both co-exist)

    JRE emulation:

    • nil_chk() has been changed to a macro, to provide better stack traces.

    JRE sources updated to latest from Android-nougat:

    • java.net
    • XML SAX support: org.xml.sax, XML drivers

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.0.4.zip(1076.58 MB)
  • 2.0.3(Aug 28, 2017)

    A new release of J2ObjC is available, 2.0.3.

    Note: -Xuse-jdt is removed in this release and the JDT code will be removed at a later time.

    Other changes include:

    J2ObjC examples:

    • Adds an example app using Bazel build rules (in /examples/Contacts).

    JRE sources updated to latest from Android-nougat:

    • java.nio
    • java.nio.channels
    • java.nio.spi

    Bug fixes:

    • Issues: #873, #875

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.0.3.zip(1077.87 MB)
  • 2.0.2(Jul 19, 2017)

    A new release of J2ObjC is available, 2.0.2. This is an update to 2.0.1 with some bug fixes and updates to the JRE runtime.

    J2ObjC translator:

    • Passing command arguments with a file using '@' now works for all flags. (previously only worked for source files)
    • Added --no-wrapper-methods flag. Helps to reduce code size by eliminating Objective-C wrappers for static methods and constructors. These can be called via generated C-style functions.

    JRE emulation:

    • java.lang.Throwable no longer maps to NSException. Instead JavaLangThrowable extends from NSException.

    JRE sources updated to latest from Android-nougat:

    • java.util (most)
    • java.util.concurrent
    • java.util.concurrent.locks
    • javax.net.ssl

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.0.2.zip(1043.06 MB)
  • 2.0.1(Jun 7, 2017)

    A new release of J2ObjC is available, 2.0.1. This is an update to 2.0 with some bug fixes and updates to the JRE runtime.

    JRE sources updated to latest from Android-nougat:

    • java.lang.reflect
    • java.lang.ref
    • java.util.concurrent.atomic
    • java.util.jar
    • java.util.logging
    • java.util.regex

    Bug fixes:

    • Issues: #858, #861, #802, #844, #856, #855
    • Fixed leaks in java.io.Reader, java.io.Writer, java.io.InputStreamReader

    Protocol Buffers:

    • Updated to build against protobur-3.3.0.
    • Added map field support.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.0.1.zip(1031.27 MB)
  • 2.0(May 9, 2017)

    A new release of J2ObjC is available, 2.0. This release uses the javac compiler as its front end, which improves the translator's Java compatibility while improving performance. If the new front end causes any problems with your project, please file a bug and then switch to the old front end using the -Xuse-jdt flag (please do so promptly, as that flag will be removed in a future release once issues requiring have been fixed).

    The http://j2objc.org website has joined the Google Developers site at https://developers.google.com/j2objc/. This gives our project better support and will make it easier to keep up to date. In particular, our API Reference is enhanced and easier to use. We'll be redirecting http://j2objc.org to this new site soon.

    This release continues the migration to the OpenJDK-based JRE source code in Android's 7.0 Nougat libcore library. Although there are some classes that still need to be migrated, we believe that all classes with Java 8 additions are now ported (please file a bug if you find otherwise).

    Other changes include:

    • Updated java.security classes using the Apache Harmony Fortress classes to instead use sun.security packages.
    • Updated date and number formatters to OpenJDK.
    • Updated date, calendar, and timezone support to OpenJDK.
    • Updated character conversion to use the iconv library in iOS.
    • Added protocol buffers oneof support.
    • Integrated several IosHttpURLConnection contributions and bug fixes.
    • j2objc performance improvements:
      • reduced size of several AST node classes,
      • skipped unnecessary validation.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-2.0.zip(1022.96 MB)
  • 1.3.1(Jan 24, 2017)

  • 1.3(Jan 18, 2017)

    A new release of J2ObjC is available, 1.3. The main focus of this release has been on improving support for Java 8, which included fixing bugs and memory cycles in the new OpenJDK code in the jre_emul library. Although Java 8 support was only introduced in 1.2, we have much higher confidence in J2ObjC's Java 8 support with this release.

    The Java 8 API support still isn’t complete; in particular, java.util.time is not available. However, since it’s also not part of Android’s libcore library (which the jre_emul library is based upon), code that uses that new package isn’t portable yet. If you find any other Java 8 classes or methods aren’t available, file a bug so we can make implementing it a priority.

    Most of our time was spent making it possible to use javac as the front-end for j2objc. We realized we needed to switch to javac for several reasons, including better Java 8 support now and faster support for future Java enhancements ("Winter (Java 9) is coming" :-). The j2objc translator still uses the Eclipse JDT as the default front-end, but plan on switching the default to javac in the next release, and dropping the JDT in a following release.

    We encourage you to test the javac front-end with your project, and report any issues you find using it. There are two ways to specify which front end to use:

    • Use the -Xuse-javac flag (there's also a -Xuse-jdt flag, which is the default); or
    • Define the environment variable J2OBJC_FRONT_END=JAVAC (or JDT) in your build tool or shell settings.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-1.3.zip(923.25 MB)
  • 1.2(Oct 13, 2016)

    A new release of J2ObjC is available, 1.2. The main focus of this release has been on adding the new packages, classes, and methods in Java 8 to the JRE emulation library. These new features include:

    • java.util.function package
    • java.util.stream package
    • Streaming support in java.io, java.lang and java.util
    • java.util.Spliterator with collection support
    • java.util.Base64
    • java.util.Optional*
    • java.util.StringJoiner and String.join()
    • java.util.Arrays.parallelSort()

    Many of these new features use lambdas in lots of interesting ways, so lambda and method reference translation was reworked, with faster execution and several bugs fixed.

    The Java 8 API support isn’t complete; in particular, java.util.time is not available. However, since it’s also not part of Android’s libcore library (which the jre_emul library is based upon), code that uses that new package isn’t portable yet. If you find any other Java 8 classes or methods aren’t available, file a bug so we can make implementing it a priority.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-1.2.zip(940.27 MB)
  • 1.1(Jul 26, 2016)

    A new release of J2ObjC is available, 1.1.

    This release updates 1.0.2 with several bug fixes, including:

    iOS:

    • Added tvOS support.

    Annotations:

    • Added RetainedWith, allowing some object pairs to form a reference cycle without leaking.

    Translator:

    • Revised lambda and method reference translation for better performance.
    • Various method reference translation bugs resolved.
    • Declares narrower return types for type variables with bounds.
    • Beginning of migration to javax.lang.model symbol types from JDT bindings.

    Runtime:

    • Volatile fields: spinlocks replaced with pthread_mutex to avoid priority inversion deadlock.
    • Improve DST support with NSTimeZone-backed TimeZone
    • Various reflection fixes, removed best effort support. (most reflection now requires metadata)
    • Reflection metadata is cleaned up to reduce effect on binary size.
    • java.lang.Thread implementation switched to use pthread instead of NSThread.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-1.1.zip(813.98 MB)
  • 1.0.2(Apr 1, 2016)

    A new release of J2ObjC is available, 1.0.2.

    This release updates 1.0.1 with several bug fixes, including:

    iOS:

    • Added WatchOS support (contributed by Harri Hohteri).

    Translator:

    • Implemented Java 8 default method support, including default methods in lambdas.
    • Correctly produce capturing lambdas.
    • Fixed memory leak when a retaining constructor throws an exception.
    • Fixed leaky annotation types by adding a dealloc method.
    • Added -source flag to cycle_finder.

    Runtime:

    • Currency formatting fixed for BigDecimal and BigInteger values.
    • Updated java.lang.annotation to Java 8, fixing type annotations.

    Libraries:

    • Guava library updated to version 19.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-1.0.2.zip(675.89 MB)
  • 1.0.1(Feb 9, 2016)

    A new release of J2ObjC is available, 1.0.1.

    This release updates 1.0.0 with several bug fixes, including:

    Translator:

    • Java enums use a shared alloc. (non-ARC only)

    Runtime:

    • java.lang.Throwable now maps to NSException. JavaLangThrowable is still supported with a @compatibility_alias, but this will be removed in the next version.
    • IosHttpURLConnection implements java.net.CookieHandler support.

    Libraries:

    • Symlinks are preserved in zipped release, reducing its size.
    • Guava library is build directly from unaltered Guava sources. Forked sources have been removed.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-1.0.1.zip(621.06 MB)
  • 1.0.0(Jan 21, 2016)

    A new release of J2ObjC is available, 1.0.0. This release removes the "beta" tag from the project, as it is now used by many iOS apps.

    In addition to numerous bug fixes and performance improvements, this release includes:

    Translator:

    • Simplified Java enum translation.
    • A --swift-friendly flag, which enables flags that make importing J2ObjC header files into Swift easier. We'll continue to improve Swift inter-operability in the future.
    • Added translation support for Java nullability annotations.
    • Added OCNI header blocks.

    Runtime:

    • Split libjre_emul.a into sub-libraries, to support developers needing smaller apps.
    • Support iOS bitcode.
    • Rewrote runtime support for volatile fields.
    • Added java.security Signature provider.

    Libraries

    • Distributed libraries can now be added to projects using static frameworks.
    • Apache Xalan library added to support the javax.xml.transform package.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-1.0.0.zip(1031.48 MB)
  • 0.9.8.2.1(Sep 29, 2015)

  • 0.9.8.2(Sep 25, 2015)

    Note: the release build for 0.9.8.2 failed, as it did not contain the Guava libraries. Use the 0.9.8.2.1 build instead.

    This release updates 0.9.8.1 with:

    Xcode 7/iOS 9 Support

    • #611: Added x86_64 simulator arch.
      • Mac OS X libraries moved to dist/lib/macosx.
    • #613: Added bitcode marker support.
    • Fixed doc-comment generation to display correctly in Xcode Quick Help.

    Improvements

    • java.util.jar added to JRE.
    • #574: added javac's -processor and -processorpath flags to j2objc.
    • A -version flag was added to j2objc and cycle_finder.
    • Added java.beans.PropertyDescriptor.
    • Added jre_emul-src.jar to distribution.
    • Added Zip64 support.

    Bug Fixes

    • Fixed type casting on inferred wildcard types.
    • Fixed issues with java.lang.ref implementation.
    • Fixed java.util.zip.ZipFile expansion of deflated zip entries.
    • #591 Implement JreAssert with macro so that msg is conditionally evaluated, contributed by @lukhnos.
    • #595 JavaMetadata leak fixes, contributed by @lukhnos.
    • #596: Fixed try-with-resources to match JLS spec.
    • #600: Improved dead code elimination, contributed by @lukhnos.
    • #602: Fixed java.lang.Throwable leaks, contributed by @lukhnos.
    • #604: Fixed java.nio leaks, contributed by @lukhnos.
    • #606: Mutex leak fixes, contributed by @lukhnos.
    • #607: Fixed runtime lookup of classes mapped with wildcard prefixes.
    Source code(tar.gz)
    Source code(zip)
  • 0.9.8(Aug 14, 2015)

    A new release of J2ObjC is available, 0.9.8.

    In addition to numerous bug fixes changes include:

    Translator:

    Runtime:

    • Fully revised java.util.concurrent.atomic implementations using c11.
    • Basic JNI support added.
    • Added java.security Signature provider.

    Protobufs

    • Added protocol string list support.

    Libraries

    • Google Guava
      • Updated to version 18.0
      • J2ObjC fork merged.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-0.9.8.zip(90.22 MB)
  • 0.9.7(Apr 10, 2015)

    A new release of J2ObjC is available, 0.9.7.

    In addition to numerous bug fixes changes include:

    Support Tools:

    • Added Protocol Buffer support.

    Performance:

    • Constructors are “functionized”.

    Translator:

    • Declarations of private inner types are moved to the implementation file.
    • Improved reflection on generic types.
    • Improved @ObjectiveCName support for methods.
    • Improved runtime annotation support.

    Runtime:

    • Added reflection support for generic signatures.

    Thanks for all the bug reports, especially those with tests and/or patches -- we're a small team, and appreciate the help!

    Source code(tar.gz)
    Source code(zip)
    j2objc-0.9.7.zip(79.93 MB)
  • 0.9.6.1(Feb 4, 2015)

Owner
Google
Google ❤️ Open Source
Google
This project is a specialized fork of Checkstyle to support older runtime environments of users who can't upgrade

checkstyle-backport-jre8 The latest release version can be found at GitHub releases or at Maven repo. This project is a specialized fork of Checkstyle

null 3 Apr 21, 2022
The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts

yGuard yGuard is an open-source Java obfuscation tool. With yGuard it is easy as pie ( ?? ) to configure obfuscation through an extensive ant task. yG

yWorks GmbH 265 Jan 2, 2023
ThirdEye is an integrated tool for realtime monitoring of time series and interactive root-cause analysis.

ThirdEye is an integrated tool for realtime monitoring of time series and interactive root-cause analysis. It enables anyone inside an organization to collaborate on effective identification and analysis of deviations in business and system metrics. ThirdEye supports the entire workflow from anomaly detection, over root-cause analysis, to issue resolution and post-mortem reporting.

null 87 Oct 17, 2022
A simplified and multi-functional tool for spigot developers

A simplified and multi-functional tool for spigot developers. There are dozens of features you can use in it, and it is completely open source code. hCore supports all versions from 1.8.x to 1.18.2. Also you can find all these APIs usages from here.

Hakan Kargın 57 Jan 1, 2023
Helper tool to calculate the price for a given amount of users within a graduated pricing model.

Lithic Hi Lithic, This small piece of software is a coding exercise I asked some candidates to solve and is based on the pricing model of Atlassian pr

Stefan Antal 1 Feb 27, 2022
A tool to help Barcelonian people get various immigration-related appointments via the Cita previa process

NIEBot A tool to help Barcelonian people get various immigration-related appointments via the Cita previa process. Requirements A Windows or Linux PC.

Conor Rynne 49 Dec 10, 2022
Sauron, the all seeing eye! It is a service to generate automated reports and track migrations, changes and dependency versions for backend services also report on known CVE and security issues.

SAURON - VERSION AND DEPLOYMENT TRACKER DESCRIPTION Sauron, the all seeing eye! It is a service to generate automated reports and track migrations, ch

FREENOWTech 20 Oct 31, 2022
A Local implementation of a java library functions to create a serverside and clientside application which will communicate over TCP using given port and ip address.

A Local implementation of java library functions to create a serverside and clientside application which will communicate over TCP using given port and ip address.

Isaac Barry 1 Feb 12, 2022
Java Notes & Codes for better understanding and it contains all the funtions with examples and also added Cheat Sheet for Revision

Java Notes & Codes for better understanding and it contains all the funtions with examples and also added Cheat Sheet for Revision...

Ujjawal Singh 1 Nov 30, 2022
A calculator that performs various operations such as addition, subtraction, multiplication and division of positive and negative values

A calculator that performs various operations such as addition, subtraction, multiplication and division of positive and negative values The calculator also does percentages, square roots and squares

Andrey Fabricio 1 Jan 31, 2022
Tripoli imports raw mass spectrometer data files and supports interactive review and archiving of isotopic data.

Tripoli imports raw mass spectrometer data files and supports interactive review and archiving of isotopic data. Tripoli facilitates visualization of temporal trends and scatter during measurement, statistically rigorous filtering of data, and calculation of statistical parameters.

CIRDLES 7 Dec 15, 2022
Automatically discover and tag PII data across BigQuery tables and apply column-level access controls based on confidentiality level.

Automatically discover and tag PII data across BigQuery tables and apply column-level access controls based on confidentiality level.

Google Cloud Platform 18 Dec 29, 2022
Make Slack and Facebook Bots in Java.

JBot Make bots in Java. JBot is a java framework (inspired by Howdyai's Botkit) to make Slack and Facebook bots in minutes. It provides all the boiler

Ram 1.2k Dec 18, 2022
API gateway for REST and SOAP written in Java.

Membrane Service Proxy Reverse HTTP proxy (framework) written in Java, that can be used as an API gateway as a security proxy for HTTP based integrati

predic8 GmbH 389 Dec 31, 2022
An extensible Java framework for building XML and non-XML streaming applications

Smooks Framework This is the Git source code repository for the Smooks Project. Build Status Building Pre-requisites JDK 8 Apache Maven 3.2.x Maven gi

Smooks Framework 353 Dec 1, 2022
fastutil extends the Java Collections Framework by providing type-specific maps, sets, lists and queues.

fastutil is a collection of type-specific Java classes that extend the Java Collections Framework by providing several containers, such as maps, sets, lists and prority queues, implementing the interfaces of the java.util package; it also provides big (64-bit) arrays, sets, lists, and fast, practical I/O classes for binary and text files.

Sebastiano Vigna 1.5k Jan 7, 2023
An example mod that uses Vigilance and Essential with Java

Vigilance Example Mod (Java) I haven't really seen any mods that use Vigilance and Essential with Java, so here's a quick example mod I made. It's bas

null 6 Dec 25, 2022
A harness to build the source code from openjdk.java.net using Free Software tools and dependencies

A harness to build the source code from openjdk.java.net using Free Software tools and dependencies

IcedTea 2 Mar 5, 2022
Implementation of various design patterns in C++, Java and Python

DesignPatterns Implementation of various design patterns in C++, Java and Python. Strategy Pattern Description: Strategy Pattern in implemented in a p

Lakshmanan Meiyappan 12 Jul 20, 2022