- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
<分区>
Possible Duplicate:
incorrect stacktrace by rethrow
人们普遍认为,在 .NET 中,throw;
不会重置堆栈跟踪,但 throw ex;
会。
但是,在这个简单的程序中,我得到了不同的行号:
void Main()
{
try
{
try
{
Wrapper(); // line 13
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
throw; // line 18
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
public void Wrapper()
{
Throw(); // line 28
}
public void Throw()
{
var x = (string)(object)1; // line 33
}
输出是:
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at ConsoleApplication2.Program.Main(String[] args) in C:\long-path\Program.cs:line 13
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at ConsoleApplication2.Program.Main(String[] args) in C:\long-path\Program.cs:line 18
注意:第一个堆栈跟踪包含第 13 行,第二个堆栈跟踪包含第 18 行。此外,第 13 行和第 18 行都不是实际发生转换的行。
我现在的问题是:throw;
在什么情况下会更改堆栈跟踪,在什么情况下不会更改堆栈跟踪?
请注意,这已经是been observed , 但一般没有回答。
更新:
我在 Debug模式下运行上面的代码,结果如下:
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at ConsoleApplication2.Program.Throw() in C:\long-path\Program.cs:line 33 at ConsoleApplication2.Program.Wrapper() in C:\long-path\Program.cs:line 28 at ConsoleApplication2.Program.Main(String[] args) in C:\long-path\Program.cs:line 13
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at ConsoleApplication2.Program.Throw() in C:\long-path\Program.cs:line 33 at ConsoleApplication2.Program.Wrapper() in C:\long-path\Program.cs:line 28 at ConsoleApplication2.Program.Main(String[] args) in C:\long-path\Program.cs:line 18
请注意:最后一行的数字仍然在变化
简介 几个月前,我们介绍了 Informer 这个模型,相关论文 ( Zhou, Haoyi, et al., 2021 ) 是一篇获得了 AAAI 2021 最佳论文奖的时间序列论文
我遇到了一个非常奇怪的问题。我的代码 fragment 看起来像这样 public Wynik getData(int pomiar, int godzina) { Wynik wynik =
在 onDestroy() 中,我使用下面的代码检查服务是否仍在运行。如果是 - 我解除绑定(bind)并停止它。 public boolean isServiceRunning(Class serv
我不熟悉使用 spark java 构建 Web 应用程序。 我正在尝试使用“之前”过滤器但出现以下错误。请帮忙。我已经在下面粘贴了我的代码。Bootstrap 是我的类具有主要方法。 Error:
我不小心在错误的分区上启动了 mount。 sda4 是包含 sdaX 的扩展分区,X>4,而我想挂载 Fat32 分区 sda7. sudo mount /dev/sda4 /media/win 现
是said in documentation, that I can set content to node, not only to string ,在信息窗口中。 不幸的是,当我尝试设置节点时,它
在所有关于 Java 的书籍中,我都读到编译器以相同的方式处理所有空白并简单地忽略额外的空白,因此最佳做法是自由使用它们以提高代码的可读性。我在我写的每一个表达式中都找到了这一点的证据:有没有空格,有
据说当我们创建 object 时的sub-class自动 objects其super-classes被创建。这是真的吗?如果是,那么如果父类(super class)是抽象类怎么办。 最佳答案 不,那
我在 if 语句中使用 map.find(key) 和 map.end() 函数: if( p_Repos->returnTypeMap().find(tc[0]) != p_Repos->retur
我尝试从 URL 中获取 id(使用 props.match.params.id)并将其传递到一个变量中以重新使用它。但是 props 是未定义的。我不知道为什么。 任何人都可以看到我是否做错了什么?
这个问题在这里已经有了答案: What is the relationship between the docker host OS and the container base image OS?
据说 libX11 不是线程安全的。这是否意味着如果我有一个已经使用 AWT(直接或通过 Swing 间接使用)的 Java 应用程序,我就不能使用除它之外的其他工具包(如 Qt,或其他使用 X11
我是一名优秀的程序员,十分优秀!