English 中文(简体)
贾瓦返回N级的警钟
原标题:Java return to position N in call stack

利用《<代码>return, Java代码中的关键词将恢复执行,使之达到“呼号”中最后一项呼吁代码。 如果物体foo,baz.bar(),return <代码>bar方法的关键词将继续在<代码>foo上执行。

请允许我表示,我反对以下文字:foofoofoo,在以上设想中打上foofoofoo, 以及foofoofoo 电话:baz.bar()。 Java是否使用<代码>return 关键词或其它东西,以便bar中的代码。 这种方法能够将所有回路退回到foo?

(成果)

最佳回答

无,是不可能的。 你们不得不在一定时间用代码处理这一紧急情况(一种例外做法是,它只是自动增加一个轨道)。

然而,这样做可能不是一个好的想法。 假设你突然需要从<条码>上打,从<条码>到<之四>>/代码>,而无需打上<条码>。 如果<条码>条码试图回到<条码>foo,现在又怎么办? 如果你只是想达到N级,那么你能否想象一下,如果你将<条码>foofoofoo合并成<条码/代码>,或将其改为<条码>foofoofoofoo,则会出现哪些问题?

完全与这一职务的正确工具相仿的一个例外:baz.bar(>,t care that it has to go to foo, 它应当知道已经发生了什么事情(,要求它放弃做什么,然后是foo。 应当知道,这种特殊情况会发生并处理(即使它只是做不到这一点)。 如果它要避免在任何事情上添加一个 throw条款,则使用不受约束的例外。

问题回答

幸运的是,在 Java是不可能的。

很少出现类似情况,例如,当你在工作环境上转而把工作推向一个协调员小组时。

但是,在应用方案中绝对是错误的。

我不是一幅巨大的 Java笑,因此我可以肯定地说,但这不是一件安全的事情,我怀疑这一点将在 Java得到支持。

现在正是这一C/C++,你可以做一个小的黑板,将压倒 st的返回地址。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签