type_obj may not be loaded, so we asynchronously load it here.
In the future, we can speed up reflection by having a synchronous_reflector
method that we can try first, and which may fail.
@cls.loader.resolve_class rs, @type, ((type_cls) =>
type_obj = type_cls.get_class_object(rs)
rv = create_obj clazz_obj, type_obj
success_fn rv
), failure_fn
return
class root.Method extends AbstractMethodField
parse_descriptor: (raw_descriptor) ->
@reset_caches = false
[__,param_str,return_str] = /\(([^)]*)\)(.*)/.exec(raw_descriptor)
param_carr = param_str.split ''
@param_types = (field while (field = util.carr2descriptor param_carr))
@param_bytes = 0
for p in @param_types
@param_bytes += if p in ['D','J'] then 2 else 1
@param_bytes++ unless @access_flags.static
@num_args = @param_types.length
@num_args++ unless @access_flags.static
@return_type = return_str
full_signature: -> "#{@cls.get_type()}::#{@name}#{@raw_descriptor}"
parse: (bytes_array, constant_pool, idx) ->
super bytes_array, constant_pool, idx
sig = @full_signature()
if (c = trapped_methods[sig])?
@code = c
@access_flags.native = true
else if @access_flags.native
if (c = native_methods[sig])?
@code = c
else
console.log(sig) if jvm.show_NYI_natives and sig.indexOf('::registerNatives()V',1) < 0 and sig.indexOf('::initIDs()V',1) < 0
if UNSAFE?
@code = null
else
@code = (rs) =>
unless sig.indexOf('::registerNatives()V',1) >= 0 or sig.indexOf('::initIDs()V',1) >= 0
rs.java_throw rs.get_bs_class('Ljava/lang/Error;'), "native method NYI: #{sig}"
else
@has_bytecode = true
@code = _.find(@attrs, (a) -> a.name == 'Code')
reflector: (rs, is_constructor=false, success_fn, failure_fn) ->
typestr = if is_constructor then 'Ljava/lang/reflect/Constructor;' else 'Ljava/lang/reflect/Method;'
exceptions = _.find(@attrs, (a) -> a.name == 'Exceptions')?.exceptions ? []
anns = _.find(@attrs, (a) -> a.name == 'RuntimeVisibleAnnotations')?.raw_bytes
adefs = _.find(@attrs, (a) -> a.name == 'AnnotationDefault')?.raw_bytes
sig = _.find(@attrs, (a) -> a.name == 'Signature')?.sig
obj = {}
clazz_obj = @cls.get_class_object(rs)
@cls.loader.resolve_class(rs, @return_type, ((rt_cls) =>
rt_obj = rt_cls.get_class_object(rs)
j = -1
etype_objs = []
i = -1
param_type_objs = []
fetch_etype = () =>
j++
if j < exceptions.length
e_desc = exceptions[j]
@cls.loader.resolve_class(rs, e_desc,
((cls)=>etype_objs[j]=cls.get_class_object(rs);fetch_etype()), failure_fn)
else