Redian新闻
>
怎么返回一个变量的地址?
avatar
怎么返回一个变量的地址?# Java - 爪哇娇娃
c*m
1
前两天看到一个面试题,怎么确定stack grow的方向,是从高地址到低地址,还是相反
。这个问题用C很容易,写两个nested function call, 在每个里面分配一个变量,然
后检查指针就行了。Java 有什么办法呢?
avatar
m*t
2
Are you sure it was an interview for a Java job?
avatar
c*m
3
I read it sometime ago on internet, and the question says, 'using java or c+
+', this really got me
avatar
m*t
4
Don't know how to do this in Java - calling a JNI function from two nested
Java methods? What's the point anyway?
avatar
c*t
5
The interpreter stack is different from the native method stack.
The interpreter stack (1) can be allocated on heaps, may be expandable,
and need not to be contiguous.
The native method stack (2) is a C calling stack, not expandable.
So using JNI would only provide you C-calling stack information.
However, maybe you could inspect the VM to generate the necessary
information for stack. Throwable.fillStackTrace() (spelling?) is
a native function call. If you have the source code of that piece
of

【在 m******t 的大作中提到】
: Don't know how to do this in Java - calling a JNI function from two nested
: Java methods? What's the point anyway?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。