indexing
	description: "This class gives Eiffel access to Java objects. You can use it directly or inherit from to and create a more convienient Eiffel class that makes the Java object look like an Eiffel object"

class interface
	JAVA_OBJECT

create 

	create_instance (my_cls: JAVA_CLASS; sig: STRING; args: JAVA_ARGS)
			-- Create an instance of the class by calling the
			-- constructor with the specified arguments. If "sig" is
			-- void then we assume that the contructor has no
			-- arguments. In that case "args" can be void
		require
			class_valid: my_cls /= void
			sig_and_args_consistent: (sig = void) implies (args = void)
		ensure
			created: java_object_id /= default_pointer

	make_from_pointer (jobject: POINTER)
			-- Create an Eiffel proxy, give a pointer to a Java object
			-- (Java object already exists)
		require
			valid_java_id: jobject /= default_pointer

feature 

	jni: JNI_ENVIRONMENT
			-- returns the standard JNI enviroment. It uses the value of
			-- CLASS_PATH environment variable to initialize the JVM
			-- (from SHARED_JNI_ENVIRONMENT)
		ensure -- from SHARED_JNI_ENVIRONMENT
			Result /= void
	
feature -- Java exception mechanism

	c_check_for_exceptions (lenv: POINTER)
			-- (from JAVA_EXTERNALS)

	c_throw_custom_exception (lenv: POINTER; jclass_id: POINTER; msg: POINTER)
			-- (from JAVA_EXTERNALS)

	c_throw_java_exception (lenv: POINTER; jthrowable: POINTER)
			-- (from JAVA_EXTERNALS)
	
feature -- access object's attributes

	boolean_attribute (fid: POINTER): BOOLEAN
			-- access to a boolean attribute

	byte_attribute (fid: POINTER): CHARACTER
			-- access to a 'byte' attribute, returns a CHARACTER

	char_attribute (fid: POINTER): CHARACTER
			-- access to a 'char' attribute

	double_attribute (fid: POINTER): DOUBLE
			-- access to a double attribute

	float_attribute (fid: POINTER): REAL
			-- access to a 'float' attribute, returns a REAL

	integer_attribute (fid: POINTER): INTEGER
			-- access to an integer attribute

	object_attribute (fid: POINTER): JAVA_OBJECT
			-- access to a java object attribute

	short_attribute (fid: POINTER): INTEGER
			-- access to a 'short' attribute, returns a INTEGER

	string_attribute (fid: POINTER): STRING
			-- access to a String attribute
	
feature -- attribute IDs

	field_id (lname: STRING; sig: STRING): POINTER
			-- Get the java field id used to set/get this field
		require
			(lname /= void) and (sig /= void)
	
feature -- call object's methods

	boolean_method (mid: POINTER; args: JAVA_ARGS): BOOLEAN
			-- Call an instance function that returns a boolean
		require
			valid_method: mid /= default_pointer

	byte_method (mid: POINTER; args: JAVA_ARGS): CHARACTER
			-- Call an instance function that return a byte
			-- ( 8-bit integer (signed) ), in Eiffel return
			-- a CHARACTER
		require
			valid_method: mid /= default_pointer

	char_method (mid: POINTER; args: JAVA_ARGS): CHARACTER
			-- Call an instance function that returns a char
		require
			valid_method: mid /= default_pointer

	double_method (mid: POINTER; args: JAVA_ARGS): DOUBLE
			-- Call an instance function that returns a DOUBLE.
		require
			valid_method: mid /= default_pointer

	float_method (mid: POINTER; args: JAVA_ARGS): REAL
			-- Call an instance function that returns a REAL.
		require
			valid_method: mid /= default_pointer

	integer_method (mid: POINTER; args: JAVA_ARGS): INTEGER
			-- Call an instance function that returns an INTEGER.
		require
			valid_method: mid /= default_pointer

	long_method (mid: POINTER; args: JAVA_ARGS)
			-- Call an instance function that returns an Long. This
			-- function is not implemented.

	object_method (lmethod_id: POINTER; args: JAVA_ARGS): JAVA_OBJECT
			-- Call an instance function that returns a java object
		require
			valid_method_id: lmethod_id /= default_pointer

	short_method (mid: POINTER; args: JAVA_ARGS): INTEGER
			-- Call an instance function that returns a Short (in
			-- Eiffel we still return an INTEGER).
		require
			valid_method: mid /= default_pointer

	string_method (mid: POINTER; args: JAVA_ARGS): STRING
			-- Call an instance function that returns a STRING.
		require
			valid_method: mid /= default_pointer

	void_method (mid: POINTER; args: JAVA_ARGS)
			-- Call a Java procedure with method_id "mid" and
			-- arguments "args.
		require
			valid_method: mid /= default_pointer
	
feature -- creation

	create_instance (my_cls: JAVA_CLASS; sig: STRING; args: JAVA_ARGS)
			-- Create an instance of the class by calling the
			-- constructor with the specified arguments. If "sig" is
			-- void then we assume that the contructor has no
			-- arguments. In that case "args" can be void
		require
			class_valid: my_cls /= void
			sig_and_args_consistent: (sig = void) implies (args = void)
		ensure
			created: java_object_id /= default_pointer

	make_from_pointer (jobject: POINTER)
			-- Create an Eiffel proxy, give a pointer to a Java object
			-- (Java object already exists)
		require
			valid_java_id: jobject /= default_pointer
	
feature -- method id's

	method_id (method_name: STRING; signature: STRING): POINTER
			-- Find the method_id for "method_name" with signature
			-- encoded by "signature"
		require
			(method_name /= void) and (signature /= void)
		ensure
			method_exists: Result /= default_pointer
	
feature -- setting object's attribute

	set_boolean_attribute (fid: POINTER; value: BOOLEAN)
			-- set a 'boolean' attribute to 'value'

	set_byte_attribute (fid: POINTER; value: CHARACTER)
			-- set a 'byte' attribute to 'value'

	set_char_attribute (fid: POINTER; value: CHARACTER)
			-- set a 'char' attribute to 'value'

	set_double_attribute (fid: POINTER; value: DOUBLE)
			-- set a 'double' attribute to 'value'

	set_float_attribute (fid: POINTER; value: REAL)
			-- set a 'float' attribute to 'value'

	set_integer_attribute (fid: POINTER; value: INTEGER)
			-- set an 'integer' attribute to 'value'

	set_object_attribute (fid: POINTER; value: JAVA_OBJECT)
			-- set a java object attribute to 'value'

	set_short_attribute (fid: POINTER; value: INTEGER)
			-- set a 'short' attribute to 'value'

	set_string_attribute (fid: POINTER; value: STRING)
			-- set a 'String' attribute to 'value'
	
invariant

	valid_proxy: java_object_id /= default_pointer
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class JAVA_OBJECT