indexing
	description: "Holds information abouy JNI environment. Potentially many JNI environments can exists at once, but more than one was never tested"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
	revision: "$Revision: 56675 $"

class interface
	JNI_ENVIRONMENT

create {JAVA_VM}
	make (vm: JAVA_VM)
			-- Create new JNI environment
		require
			vm_not_void: vm /= Void

feature -- Access

	generating_type: STRING_8
			-- Name of current object's generating type
			-- (type of which it is a direct instance)
			-- (from ANY)

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
	
feature -- Comparison

	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		ensure -- from ANY
			shallow_implies_deep: standard_equal (some, other) implies Result
			both_or_none_void: (some = Void) implies (Result = (other = Void))
			same_type: (Result and (some /= Void)) implies some.same_type (other)
			symmetric: Result implies deep_equal (other, some)

	frozen equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		ensure -- from ANY
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

	is_equal (other: like Current): BOOLEAN
			-- Is `other' attached to an object considered
			-- equal to current object?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			symmetric: Result implies other.is_equal (Current)
			consistent: standard_is_equal (other) implies Result

	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		ensure -- from ANY
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

	frozen standard_is_equal (other: like Current): BOOLEAN
			-- Is `other' attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of `other' (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of `other'?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
	
feature -- Duplication

	copy (other: like Current)
			-- Update current object using fields of object attached
			-- to `other', so as to yield equal objects.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_equal: is_equal (other)

	frozen deep_copy (other: like Current)
			-- Effect equivalent to that of:
			--		copy (`other' . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)

	frozen deep_twin: like Current
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		ensure -- from ANY
			deep_equal: deep_equal (Current, Result)

	frozen standard_copy (other: like Current)
			-- Copy every field of `other' onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)

	frozen standard_twin: like Current
			-- New object field-by-field identical to `other'.
			-- Always uses default copying semantics.
			-- (from ANY)
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)

	frozen twin: like Current
			-- New object equal to `Current'
			-- twin calls copy; to change copying/twining semantics, redefine copy.
			-- (from ANY)
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result.is_equal (Current)
	
feature -- Basic operations

	frozen default: like Current
			-- Default value of object's type
			-- (from ANY)

	frozen default_pointer: POINTER
			-- Default value of type `POINTER'
			-- (Avoid the need to write `p'.default for
			-- some `p' of type `POINTER'.)
			-- (from ANY)

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
	
feature -- Array manipulation

	get_array_length (jarray: POINTER): INTEGER_32
			-- Number of elements in `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_boolean_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_byte_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_char_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_double_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_float_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_int_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_long_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_object_array_element (jarray: POINTER; indx: INTEGER_32): POINTER
			-- Item at index `indx' in `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	get_short_array_elements (jarray: POINTER; is_copy: POINTER): POINTER
			-- Acquire area of `jarray'.
		require
			jarray_not_null: jarray /= default_pointer

	release_boolean_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_byte_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_char_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_double_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_float_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_int_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_long_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	release_short_array_elements (jarray: POINTER; elts: POINTER; mode: INTEGER_32)
			-- Release area of `jarray' pointed by `elts'.
		require
			jarray_not_null: jarray /= default_pointer
			elts_not_null: elts /= default_pointer

	set_object_array_element (jarray: POINTER; indx: INTEGER_32; v: POINTER)
			-- Put `v' at index `indx' in `jarray'.
		require
			jarray_not_null: jarray /= default_pointer
	
feature -- Calls

	call_boolean_method (oid: POINTER; mid: POINTER; args: POINTER): BOOLEAN
			-- Call function `mid' with argument `args' on object `oid'.

	call_byte_method (oid: POINTER; mid: POINTER; args: POINTER): INTEGER_8
			-- Call function `mid' with argument `args' on object `oid'.

	call_char_method (oid: POINTER; mid: POINTER; args: POINTER): CHARACTER_8
			-- Call function `mid' with argument `args' on object `oid'.

	call_double_method (oid: POINTER; mid: POINTER; args: POINTER): REAL_64
			-- Call function `mid' with argument `args' on object `oid'.

	call_float_method (oid: POINTER; mid: POINTER; args: POINTER): REAL_32
			-- Call function `mid' with argument `args' on object `oid'.

	call_int_method (oid: POINTER; mid: POINTER; args: POINTER): INTEGER_32
			-- Call function `mid' with argument `args' on object `oid'.

	call_long_method (oid: POINTER; mid: POINTER; args: POINTER): INTEGER_64
			-- Call function `mid' with argument `args' on object `oid'.

	call_object_method (oid: POINTER; mid: POINTER; argsp: POINTER): POINTER
			-- Call function `mid' with argument `args' on object `oid'.

	call_short_method (oid: POINTER; mid: POINTER; args: POINTER): INTEGER_16
			-- Call function `mid' with argument `args' on object `oid'.

	call_string_method (oid: POINTER; mid: POINTER; args: POINTER): STRING_8
			-- Call function `mid' with argument `args' on object `oid'.

	call_void_method (oid: POINTER; mid: POINTER; args: POINTER)
			-- Call function `mid' with argument `args' on object `oid'.
	
feature -- Convenience

	get_string (a_str: POINTER): STRING_8
			-- Create new instance of STRING using `a_str'.
		require
			a_str_not_null: a_str /= default_pointer
	
feature -- Disposal

	destroy_vm
			-- Destroy the JVM and reclaim its ressources
			-- It can only be used in the main thread when it is the
			-- last remaining thread
	
feature -- Exception mechanism

	check_for_exceptions
			-- Check if a Java exception occurred, raise Java exception occurred

	throw_custom_exception (jclass: JAVA_CLASS; msg: STRING_8)
			-- Constructs an exception object from the specified class 'jclass'
			-- with the message specified by 'msg' and causes that exception 
			-- to be thrown. 

	throw_java_exception (jthrowable: JAVA_OBJECT)
			-- throw the exception 'jthrowable' (must be a java.lang.Throwable object)
	
feature -- Field Access

	get_boolean_field (oid: POINTER; fid: POINTER): BOOLEAN
			-- Value of attribute `fid' in object `oid'.

	get_byte_field (oid: POINTER; fid: POINTER): INTEGER_8
			-- Value of attribute `fid' in object `oid'.

	get_char_field (oid: POINTER; fid: POINTER): CHARACTER_8
			-- Value of attribute `fid' in object `oid'.

	get_double_field (oid: POINTER; fid: POINTER): REAL_64
			-- Value of attribute `fid' in object `oid'.

	get_float_field (oid: POINTER; fid: POINTER): REAL_32
			-- Value of attribute `fid' in object `oid'.

	get_integer_field (oid: POINTER; fid: POINTER): INTEGER_32
			-- Value of attribute `fid' in object `oid'.

	get_long_field (oid: POINTER; fid: POINTER): INTEGER_64
			-- Value of attribute `fid' in object `oid'.

	get_object_field (oid: POINTER; fid: POINTER): POINTER
			-- Value of attribute `fid' in object `oid'.

	get_short_field (oid: POINTER; fid: POINTER): INTEGER_16
			-- Value of attribute `fid' in object `oid'.

	get_string_field (oid: POINTER; fid: POINTER): STRING_8
		require
			oid_not_null: oid /= default_pointer
			fid_not_null: fid /= default_pointer
	
feature -- Field setting

	set_boolean_field (oid: POINTER; fid: POINTER; v: BOOLEAN)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_byte_field (oid: POINTER; fid: POINTER; v: INTEGER_8)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_char_field (oid: POINTER; fid: POINTER; v: CHARACTER_8)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_double_field (oid: POINTER; fid: POINTER; v: REAL_64)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_float_field (oid: POINTER; fid: POINTER; v: REAL_32)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_integer_field (oid: POINTER; fid: POINTER; v: INTEGER_32)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_long_field (oid: POINTER; fid: POINTER; v: INTEGER_64)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_object_field (oid: POINTER; fid: POINTER; v: POINTER)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_short_field (oid: POINTER; fid: POINTER; v: INTEGER_16)
			-- Set attribute `fid' with value `v' in object `oid'.

	set_string_field (oid: POINTER; fid: POINTER; v: STRING_8)
		require
			oid_not_null: oid /= default_pointer
			fid_not_null: fid /= default_pointer
			v_not_void: v /= Void
		ensure
			string_field_set: v.is_equal (get_string_field (oid, fid))
	
feature -- Java exception mechanism

	c_throw_custom_exception (lenv: POINTER; jclass_id: POINTER; msg: POINTER)

	c_throw_java_exception (lenv: POINTER; jthrowable: POINTER)
	
feature -- Object creation

	new_boolean_array (a_size: INTEGER_32): POINTER
			-- Create a new array of boolean.
		require
			a_size_positive: a_size >= 0

	new_byte_array (a_size: INTEGER_32): POINTER
			-- Create a new array of byte.
		require
			a_size_positive: a_size >= 0

	new_char_array (a_size: INTEGER_32): POINTER
			-- Create a new array of char.
		require
			a_size_positive: a_size >= 0

	new_double_array (a_size: INTEGER_32): POINTER
			-- Create a new array of double.
		require
			a_size_positive: a_size >= 0

	new_float_array (a_size: INTEGER_32): POINTER
			-- Create a new array of float.
		require
			a_size_positive: a_size >= 0

	new_int_array (a_size: INTEGER_32): POINTER
			-- Create a new array of int.
		require
			a_size_positive: a_size >= 0

	new_long_array (a_size: INTEGER_32): POINTER
			-- Create a new array of long.
		require
			a_size_positive: a_size >= 0

	new_object (cls: POINTER; constructor: POINTER; args: POINTER): POINTER
			-- Create a new instance of `cls' using feature `constructor' and
			-- arguments `args'.

	new_object_array (a_size: INTEGER_32; element_class: POINTER; init_elt: POINTER): POINTER
			-- Create a new array of reference of type `element_class'.
		require
			a_size_positive: a_size >= 0
			element_class_not_null: element_class /= default_pointer

	new_short_array (a_size: INTEGER_32): POINTER
			-- Create a new array of short.
		require
			a_size_positive: a_size >= 0

	new_string (v: STRING_8): POINTER
			-- Create a new java string from `v'.
	
feature -- Output

	io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of tagged_out.
			-- (from ANY)

	print (some: ANY)
			-- Write terse external representation of `some'
			-- on standard output.
			-- (from ANY)

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of out.
			-- (from ANY)
	
feature -- Platform

	operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
	
feature -- Reflection

	find_class (name: STRING_8): JAVA_CLASS
			-- Load in the Java class with the given name.
			-- Namespace if any are delimited by `/'
		require
			name_valid: name /= Void

	find_class_by_pointer (classp: POINTER): JAVA_CLASS
			-- Get a Java class Eiffel proxy given pointer to the 
			-- Java class. Create a new one if needed
		require
			classp_not_null: classp /= default_pointer

	find_class_pointer (name: STRING_8): POINTER
			-- Find class pointer only (used during creation in descendants).
			-- Namespace if any are delimited by `/'

	get_class (an_obj: POINTER): POINTER
			-- Get associated class of `an_obj'.
		require
			an_obj_not_null: an_obj /= default_pointer

	get_field_id (cls: POINTER; fname, sig: POINTER): POINTER
			-- Find attribute `mname' in class `cls' with signature `sig'.

	get_method_id (cls: POINTER; mname: POINTER; sig: POINTER): POINTER
			-- Find feature `mname' in class `cls' with signature `sig'.

	get_static_field_id (cls: POINTER; fname, sig: POINTER): POINTER
			-- Find static attribute `mname' in class `cls' with signature `sig'.

	get_static_method_id (cls: POINTER; mname: POINTER; sig: POINTER): POINTER
			-- Find static feature `mname' in class `cls' with signature `sig'.
	
feature -- Static Field access

	get_static_boolean_field (cls: POINTER; fid: POINTER): BOOLEAN
			-- Value of attribute `fid' in static `cls'.

	get_static_byte_field (cls: POINTER; fid: POINTER): INTEGER_8
			-- Value of attribute `fid' in static `cls'.

	get_static_char_field (cls: POINTER; fid: POINTER): CHARACTER_8
			-- Value of attribute `fid' in static `cls'.

	get_static_double_field (cls: POINTER; fid: POINTER): REAL_64
			-- Value of attribute `fid' in static `cls'.

	get_static_float_field (cls: POINTER; fid: POINTER): REAL_32
			-- Value of attribute `fid' in static `cls'.

	get_static_integer_field (cls: POINTER; fid: POINTER): INTEGER_32
			-- Value of attribute `fid' in static `cls'.

	get_static_long_field (cls: POINTER; fid: POINTER): INTEGER_64
			-- Value of attribute `fid' in static `cls'.

	get_static_object_field (cls: POINTER; fid: POINTER): POINTER
			-- Value of attribute `fid' in static `cls'.

	get_static_short_field (cls: POINTER; fid: POINTER): INTEGER_16
			-- Value of attribute `fid' in static `cls'.

	get_static_string_field (cls: POINTER; fid: POINTER): STRING_8
		require
			cls_not_null: cls /= default_pointer
			fid_not_null: fid /= default_pointer
	
feature -- Static calls

	call_static_boolean_method (cls: POINTER; mid: POINTER; argp: POINTER): BOOLEAN
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_byte_method (cls: POINTER; mid: POINTER; argp: POINTER): INTEGER_8
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_char_method (cls: POINTER; mid: POINTER; argp: POINTER): CHARACTER_8
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_double_method (cls: POINTER; mid: POINTER; argp: POINTER): REAL_64
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_float_method (cls: POINTER; mid: POINTER; argp: POINTER): REAL_32
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_int_method (cls: POINTER; mid: POINTER; argp: POINTER): INTEGER_32
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_long_method (cls: POINTER; mid: POINTER; argp: POINTER): INTEGER_64
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_object_method (cls: POINTER; mid: POINTER; argp: POINTER): POINTER
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_short_method (cls: POINTER; mid: POINTER; argp: POINTER): INTEGER_16
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.

	call_static_string_method (cls: POINTER; mid: POINTER; argsp: POINTER): STRING_8
		require
			cls_not_null: cls /= default_pointer
			mid_not_null: mid /= default_pointer
			argsp_not_null: argsp /= default_pointer

	call_static_void_method (cls: POINTER; mid: POINTER; argp: POINTER)
			-- Call static feature `mid' defined in class `cls' with arguments `argp'.
	
feature -- Static field setting

	set_static_boolean_field (cls: POINTER; fid: POINTER; v: BOOLEAN)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_byte_field (cls: POINTER; fid: POINTER; v: INTEGER_8)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_char_field (cls: POINTER; fid: POINTER; v: CHARACTER_8)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_double_field (cls: POINTER; fid: POINTER; v: REAL_64)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_float_field (cls: POINTER; fid: POINTER; v: REAL_32)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_integer_field (cls: POINTER; fid: POINTER; v: INTEGER_32)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_long_field (cls: POINTER; fid: POINTER; v: INTEGER_64)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_object_field (cls: POINTER; fid: POINTER; v: POINTER)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_short_field (cls: POINTER; fid: POINTER; v: INTEGER_16)
			-- Set attribute `fid' with value `v' in class `cls'.

	set_static_string_field (cls: POINTER; fid: POINTER; value: STRING_8)
		require
			cls_not_null: cls /= default_pointer
			fid_not_null: fid /= default_pointer
			value_not_void: value /= Void
		ensure
			static_string_field_set: value.is_equal (get_static_string_field (cls, fid))
	
feature -- Thread Mechanism

	attach_current_thread
			-- Attach jvm to current thread.

	detach_current_thread
			-- Detach jvm from current thread.
	
invariant
	jvm_not_void: jvm /= Void
	java_class_table_not_void: java_class_table /= Void
	java_object_table_not_void: java_object_table /= Void

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

indexing
	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		356 Storke Road, Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class JNI_ENVIRONMENT