borisbrodski / sevenzipjbinding

7-Zip-JBinding
http://sevenzipjbind.sourceforge.net/
Other
176 stars 50 forks source link

Add Android Java support #39

Closed omicronapps closed 3 years ago

omicronapps commented 3 years ago

For review. Please update as needed. Should be cleaned up before merging.

borisbrodski commented 3 years ago

Hey Fredrik,

I managed to integrate the android version into my main code. A very simple android test-app runs on my smartphone compressing and decompressing files :+1:

Now I have one question considering 'build.gradle':

ext {
    bintrayRepo = '7-Zip-JBinding-4Android'
    bintrayName = 'net.sf.sevenzipjbinding'
    libraryName = 'sevenzipjbinding'

    publishedGroupId = 'net.sf.sevenzipjbinding'
    artifact = 'sevenzipjbinding'
    libraryVersion = '16.02-2.01'

    libraryDescription = 'Android Java wrapper for 7z archiver engine'
    siteUrl = 'https://github.com/omicronapps/7-Zip-JBinding-4Android'
    gitUrl = 'https://github.com/omicronapps/7-Zip-JBinding-4Android.git'

    developerId = 'omicronapps'
    developerName = 'Fredrik Claesson'
    developerEmail = 'info@omicronapplications.com'

    licenseName = 'GNU Lesser General Public License, version 2.1'
    licenseUrl = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html'
    allLicenses = ["LGPL-2.1"]
}

What should I do with the developerId and stuff. I suppose, you will have to publish the library yourself with your id or I will have to change it to my id. Of course, I don't want to come at your authorship in any way. So how should I handle this situation?

Maybe I can change developerId to mine, but leave developerName and developerEmail yours? Or enter two developers with one id?

I also have some thought about classloader issue. What if we would find all the classes in the Java-part and then simply pass class references to the JNI? I have to test, if env->findClass() returns the same reference, as MyClass.class, and if not, can we convert one into another. I will play with it after I managed to check the code in. I would like to create an environment, where I can easily test the code against JVM and against Android quickly from the console.

Thank you!

Greetings to California :-)

Cheers and stay safe, Boris

omicronapps commented 3 years ago

Hello Boris,

I managed to integrate the android version into my main code. A very simple android test-app runs on my smartphone compressing and decompressing files šŸ‘

That's great! I checked out the android branch, and I believe the changes I madeĀ were merged as-is. Just note that a lot of the Java code in particularĀ needs some cleaning up first, but I think you will have a better idea of how this code should be arranged so that it matches the rest of the library.

For example, there shouldn't need be a hardcoded "SEVENZIPJBINDING_LIB_PROPERTIES" string in SevenZip.java. I only added that to allow the unit tests to pass, There are also other places in SevenZip.java that should be cleaned up first.

What should I do with the developerId and stuff. I suppose, you will have to publish the library yourself with your id or I will have to change it to my id. Of course, I don't want to come at your authorship in any way. So how should I handle this situation?

Maybe I can change developerId to mine, but leave developerName and developerEmail yours? Or enter two developers with one id?

I'm not too concerned with the developerId etc, so it's ok if it's not me publishing the AAR (Android Archive) libraries. In any case, one problem I am facing is that I can not sync the AAR from JFrog Bintray to JCenter since this conflicts with the package name for the existing JAR libraries. It may be a limitation that only one account holder can manage both the AAR and JAR libraries for the same package name.

Separately, both Bintray and JCenter are getting deprecated, so will maybe need to look at Maven instead anyway?... Reference: JCenter deprecation and end of service.

I also have some thought about classloader issue. What if we would find all the classes in the Java-part and then simply pass class references to the JNI? I have to test, if env->findClass() returns the same reference, as MyClass.class, and if not, can we convert one into another. I will play with it after I managed to check the code in. I would like to create an environment, where I can easily test the code against JVM and against Android quickly from the console.

I would suggest the following:

  1. findClass test app Developing and testing findClass() native thread access with the full sevenzip library is heavy and slow. For testing this it would be best to have a stand-alone app (main() based for JAR, and Activity based for AAR) that allows quick prototyping of this feature.

  2. findClass abstraction Replace any direct JNI access to findClass() in the library with a custom defined method, This will us to easily swap out the findClass() implementation as needed, and provide different implementations for JAR and AAR if necessary. The same idea of abstraction would apply to getting a temporary file, and creating a file in the file system.

Regards, Fredrik