-
Notifications
You must be signed in to change notification settings - Fork 133
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
Framework target: using Java classes as native ObjC #457
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tomClass java object natively from objc/swift. It was not possible as to use class its metadata have to be available as OBJC_CLASS_$_{class_name}. Otherwise compilation fails on linkage stage. RoboVM doesn't generate static metadata. Instead it creates ObjC classes dynamically runtime. To achieve following was done: - for each CustomClass OBJC_CLASS_$_{class_name} structure is allocated compilation time; - OBJC_CLASS_$_{class_name} structs being filled with data once Java class is loaded and corresponding ObjC class is created; - framework support is modified to preload all CustomClasses exposed by Framework when framework loads ObjCMemberPlugin: - <cinit> modified to copy ObjCClass.getHandle into OBJC_CLASS_$_{class_name} - also it replaces the handle in ObjCClass. with pointer to OBJC_CLASS_$_{class_name} (so both Java and native side will have same Class pointer) FrameworkTarget: - all OBJC_CLASS_$_{class_name} added to exported symbols ClassCompiler: - added compiler for $publishObjClass in CustomClass Linker: - added functionality to embed global symbols. In particular this is required to export list of classes to preload in _bcFrameworkPreloadClasses Frameworksupport: - now it starts VM once framework is loaded - also it preload required custom classes - old functionality maintained to allow old code that was using rvmInstantiateFramework to work
… no such item anymore in framework target
…k.name and framework.executable are different broken framework was produced
…k.name and framework.executable are different broken framework was produced
Very cool stuff! |
dkimitsa
added a commit
to dkimitsa/robovm
that referenced
this pull request
Apr 9, 2020
* * FrameworkTarget: exporting OBJC_CLASS to allow instantiation of CustomClass java object natively from objc/swift. It was not possible as to use class its metadata have to be available as OBJC_CLASS_$_{class_name}. Otherwise compilation fails on linkage stage. RoboVM doesn't generate static metadata. Instead it creates ObjC classes dynamically runtime. To achieve following was done: - for each CustomClass OBJC_CLASS_$_{class_name} structure is allocated compilation time; - OBJC_CLASS_$_{class_name} structs being filled with data once Java class is loaded and corresponding ObjC class is created; - framework support is modified to preload all CustomClasses exposed by Framework when framework loads ObjCMemberPlugin: - <cinit> modified to copy ObjCClass.getHandle into OBJC_CLASS_$_{class_name} - also it replaces the handle in ObjCClass. with pointer to OBJC_CLASS_$_{class_name} (so both Java and native side will have same Class pointer) FrameworkTarget: - all OBJC_CLASS_$_{class_name} added to exported symbols ClassCompiler: - added compiler for $publishObjClass in CustomClass Linker: - added functionality to embed global symbols. In particular this is required to export list of classes to preload in _bcFrameworkPreloadClasses Frameworksupport: - now it starts VM once framework is loaded - also it preload required custom classes - old functionality maintained to allow old code that was using rvmInstantiateFramework to work * * FrameworkTarget: template updated to match ObjC changes * * FrameworkTarget: idea -- removed main class from wizard as there is no such item anymore in framework target * * FrameworkTarget: template -- fixed imageName, otherwise if framework.name and framework.executable are different broken framework was produced * * FrameworkTarget: template -- fixed imageName, otherwise if framework.name and framework.executable are different broken framework was produced * * fixed typos
dkimitsa
added a commit
to dkimitsa/robovm
that referenced
this pull request
Apr 9, 2020
* * FrameworkTarget: exporting OBJC_CLASS to allow instantiation of CustomClass java object natively from objc/swift. It was not possible as to use class its metadata have to be available as OBJC_CLASS_$_{class_name}. Otherwise compilation fails on linkage stage. RoboVM doesn't generate static metadata. Instead it creates ObjC classes dynamically runtime. To achieve following was done: - for each CustomClass OBJC_CLASS_$_{class_name} structure is allocated compilation time; - OBJC_CLASS_$_{class_name} structs being filled with data once Java class is loaded and corresponding ObjC class is created; - framework support is modified to preload all CustomClasses exposed by Framework when framework loads ObjCMemberPlugin: - <cinit> modified to copy ObjCClass.getHandle into OBJC_CLASS_$_{class_name} - also it replaces the handle in ObjCClass. with pointer to OBJC_CLASS_$_{class_name} (so both Java and native side will have same Class pointer) FrameworkTarget: - all OBJC_CLASS_$_{class_name} added to exported symbols ClassCompiler: - added compiler for $publishObjClass in CustomClass Linker: - added functionality to embed global symbols. In particular this is required to export list of classes to preload in _bcFrameworkPreloadClasses Frameworksupport: - now it starts VM once framework is loaded - also it preload required custom classes - old functionality maintained to allow old code that was using rvmInstantiateFramework to work * * FrameworkTarget: template updated to match ObjC changes * * FrameworkTarget: idea -- removed main class from wizard as there is no such item anymore in framework target * * FrameworkTarget: template -- fixed imageName, otherwise if framework.name and framework.executable are different broken framework was produced * * FrameworkTarget: template -- fixed imageName, otherwise if framework.name and framework.executable are different broken framework was produced * * fixed typos
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the way Java code might be used in ObjC/Swift project by exposing java @CustomClass object to native side, so these can be instantiated directly as simple as [[MyClass alloc] init] and JVM is started automatically.
For this:
OBJC_CLASS_$_${CLASSNAME}
symbols that is needed at native part during linkage;OBJC_CLASS_$_${CLASSNAME}
once backing ObjC class is dynamically created runtime once Java class is loaded;