Important: The information in this document is obsolete and should not be used for new development.
In Objective-C, you can use Java classes and interfaces as if they were Objective-C classes and protocols.
To reference class objects, you must use the function
NSClassFromString()
, since the Objective-C compiler can't generate static references to bridged Java classes. For example, to instantiate an object from the
AJavaClass
class, you would write code such as the following:
MyJavaClass = NSClassFromString(@"java.util.AJavaClass"); MyJavaObj = [[MyJavaClass alloc] init];
You can instantiate Java classes from Objective-C and see them as if they were pure Objective-C objects. You can also pass Objective-C objects as parameters to Java methods.
To invoke a Java method from Objective-C:
.jobs
file, your specified Java method name is used.
.jobs
file, the bridge automatically derives the Java method name from the Objective-C selector name by removing everything beyond the first colon. Thus, a method such as
sendBar:x foo:y
would map to
sendBar(x,y)
Exceptions raised within the Java code are caught and transformed into NSExceptions, which can then be handled by your code on the Objective-C side.