-
Notifications
You must be signed in to change notification settings - Fork 6
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
allows static method calls on JNIObject
#14
Conversation
try checkAndThrowOnJNIError() | ||
self.javaClass = javaClass! | ||
self.instance = globalInstanceRef | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good overall, but we should deprecate the current convenience init and force use of the new API where users have to override className
(it's weird to have a convenience init with className
here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best way to do that would be to add
@available(*, deprecated, message: "Override Self.className instead and use the initializers that don't take className as an argument")
convenience public init(_ className: String, arguments: [JavaParameterConvertible] = []) throws {
// deprecated init
}
// note the variadic arguments syntax instead of the array
convenience public init(...arguments: [JavaParameterConvertible]) throws {
// use `Self.javaClass` here
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the idea and i commited the changes. One thing, Self
does not seem to be available here and i used type(of: self).javaClass
to workaround it. Not really understanding why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sources/JNI/JNIObjects.swift
Outdated
|
||
private static var classInstances = [String: JavaClass]() | ||
|
||
public class var javaClass: JavaClass { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be static now I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you are right
thanks for your help & guidance @ephemer |
@michael my pleasure! Thanks for putting this PR in |
No description provided.