NSJavaVirtualMachine.h 2.5 KB
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/*
 * NSJavaVirtualMachine.h
 *
 * Copyright (c) 1997-2001, Apple Computer, Inc.
 * All Rights Reserved.
 */

#import <Foundation/Foundation.h>

@interface NSJavaVirtualMachine : NSObject
{
@private
    void *_vmdata;
}


// Returns the default virtual machine - if necessary, calls alloc + init

+ (id) defaultVirtualMachine DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;

// Returns a class path.  First checks NSProcessInfo for an environment variable
// called CLASSPATH and if that doesn't exist, uses NSJavaConfiguration to find
// the default class path.

+ (NSString *) defaultClassPath DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;

// Note that any NSThreads spawned after this method returns will automatically 
// be attached to the virtual machine.  Likewise, it is not necessary to attach
// the thread that is actually creating the virtual machine.  If you spawn a
// thread before creating the virtual machine, or if you use the cthread/pthread
// or any other non-NSThread api for creating a thread, you must explicitly
// attach those threads before messaging any Java object from that thread.
// This is most easily done by using the -attachCurrentThread method.
// Use -detachCurrentThread to detach explicitly attached threads when done.

- initWithClassPath:(NSString *)classPath DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;

- (void) attachCurrentThread DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
- (void) detachCurrentThread DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;

- (Class)findClass:(NSString *)className DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
- (Class)defineClass:(NSData *)javaClassData withName:(NSString *)className DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;

@end


@interface NSObject (InstantiatingJavaObjects)

// Instantiating java objects for when no -init/constructor mapping works.
// The class these methods are invoked on *must* be a class returned by the
// -findClass: method (or NSClassFromString() function), otherwise
// NSInvalidJavaClassException is raised. The signature is specified using the
// rather counter-intuitive format defined by the Java Virtual Machine
// specification.  Try looking in JavaVM/vm-interface.h for help.

+ (id) newWithSignature:(NSString *)signature, ... DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
+ (id) newWithSignature:(NSString *)signature arguments:(va_list)args DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;

@end

extern NSString *NSInvalidJavaClassException DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;