Skip to content

erjang.EModuleManager$ModuleInfo warn_about_unresolved #36

Closed
robertlj opened this Issue Nov 10, 2010 · 5 comments

2 participants

@robertlj

After compiling Erlang version R14B and setting my environment variables to:

ERTS_VSN=5.8.1

ERL_ROOT=/home/robert/bob-apps/erlang-for-erjang-R14B/lib/erlang

When I run ./ej i receive the following:

#-
robertlj@rj:~/bob-repos/erjang_working$ ./ej
Nov 10, 2010 10:45:53 AM erjang.EModuleManager$ModuleInfo warn_about_unresolved
INFO: unresolved after load: code:is_module_native/1
Eshell V5.8.1 (abort with ^G)
1>
#-

#-
System OS: Ubuntu 10.10 (Maverick Meerkat)
Erlang: compiled from erlang.org source

Example of my "env_cfg"

#-
if [[ -z ${ERTS_VSN} ]]; then
ERTS_VSN=5.8.1
fi
if [[ -z ${ERL_ROOT} ]]; then
ERL_ROOT=/home/robert/my-apps/erlang-for-erjang-R14B/lib/erlang
fi
#-

@krestenkrab
Trifork member

The "warn about unresolved" warnings are just that: a warning. A module contains an external reference to a BIF/function which does not exist in the target module; and it's not an issue until that BIF/function gets called.

So, consider it a hint that if you see a crash soon after this, consider if the given BIF/function needs to be implemented.

For instance, when you do "q()." you'll ge a warning that kernel:prep_stop is missing. But that's not a problem; ... rather an optional callback API for applications.

So ... until Erjang is a little more complete; I'd like to keep these warnings. But we could easily create an option to enable/disable them.

If you want to implement the BIF, it's quite easy. My guess is that for Erjang we can just always return false, ... and so this would be the implementation: (put this in src/main/java/erjang/m/code)

package erjang.m.code;
import erjang.*;
class Native extends erjang.ENative {
   @BIF
    public static EObject is_module_native(EObject module) {
        return ERT.FALSE;
    }
}
@robertlj

Thanks for the information. On my machine I created a "code" directory under "src/main/java/erjang/m/". Then I created a "Native.java" source file under the "code" directory. I ran "ant" in the top directory to build the code. After the build succeded I ran ./ej . The system crashed after giving the following error:

#-

robert@rl:~/bob-repos/erjang_robert_contrib$ ./ej
Nov 11, 2010 12:41:39 PM erjang.m.erlang.ErlBif load_module
SEVERE: cannot load module code
java.lang.Error: cannot instantiate Natives for module code
at erjang.EModule.load_native_bifs(EModule.java:79)
at erjang.beam.ECompiledModule.registerImportsAndExports(ECompiledModule.java:95)
at erjang.m.code.code.registerImportsAndExports(code.S)
at erjang.EModuleManager.setup_module(EModuleManager.java:425)
at erjang.EModule.setup(EModule.java:39)
at erjang.EModule.(EModule.java:36)
at erjang.EModule.(EModule.java:31)
at erjang.beam.ECompiledModule.(ECompiledModule.java:36)
at erjang.m.code.code.(code.S)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at erjang.EModuleLoader.load_compiled_module(EModuleLoader.java:154)
at erjang.EModuleLoader.load_module(EModuleLoader.java:83)
at erjang.ERT.load_module(ERT.java:979)
at erjang.m.erlang.ErlBif.load_module(ErlBif.java:1396)
at erjang.m.erlang.ErlBif.load_module(ErlBif.java:1387)
at erjang.m.init.init.load_mod_code__3(init.S:421)
at erjang.m.init.init$FN_load_mod_code__3.go(Unknown Source)
at erjang.m.init.init.load_mod__2$call(init.S)
at erjang.m.init.init.ensure_loaded__2(init.S:135)
at erjang.m.init.init.boot_loop__2(init.S:112)
at erjang.m.init.init$FN_boot_loop__2.go(Unknown Source)
at erjang.EProc.execute(EProc.java:500)
at kilim.Task._runExecute(Task.java:400)
at kilim.WorkerThread.run(WorkerThread.java:47)
Caused by: java.lang.IllegalAccessException: Class erjang.EModule can not access a member of class erjang.m.code.Native with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95)
at java.lang.Class.newInstance0(Class.java:366)
at java.lang.Class.newInstance(Class.java:325)
at erjang.EModule.load_native_bifs(EModule.java:77)
... 28 more
{error_logger,{{2010,11,11},{12,41,39}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,{'EXIT',{undef,[{code,start_link,[]},{erlang,apply,3},{supervisor,do_start_child,2},{supervisor,start_children,3},{supervisor,init_children,2},{gen_server,init_it,6},{erlang,apply,3},{proc_lib,init_p_do_apply,3}]}}},{offender,[{pid,undefined},{name,code_server},{mfargs,{code,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2010,11,11},{12,41,39}},std_info,[{application,kernel},{exited,{shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}})

#-

Did I implement the code in the correct way? Am I missing something?

@krestenkrab
Trifork member

Hmm, looks like something in your class erjang.m.code.Native is not public. If it is not the method is_module_native, then try adding a public no-arg constructor.

@robertlj

That was the problem. Native needed to be public.

@krestenkrab
Trifork member

thanks

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.