- 浏览: 30708 次
- 性别:
- 来自: 厦门
最新评论
Eclipse debug 的五个技巧
- 博客分类:
- java编程
Logical Structure
The logical structure is very handy for examining things like maps and other java collections classes, instead of showing the full detail of all the internal variables the view will only show the “logical” pieces. It is activated/deactivated from “Variables” view using logical structure toggle button.
[Code Sample]
[Logical Structure - Deactivated]
[Logical Structure - Activated]
Conditional Debugging
Once you know where an error occurs, you will want to see what the program is doing right before it crashes. One way to do this is to step through every statement in the program, one at a time, until you reach the point of concern. Sometimes it’s better to just run a section of code and stop execution at that point so you can examine data at that location. It’s possible to declare conditional breakpoints triggered whenever the value of an expression changes. In addition, code assist is available when typing in the conditional expression.
Right click your breakpoint and select Breakpoint Properties… to set a condition. Check “Enable Condition” box and write your expression below it. You can define a “hit count” that stops your code after that count is reached if you want.
[Conditional Debugging]
Java Exception Breakpoint
Use “Java Exception Breakpoint” feature to track your exceptions more easily. For example, your program might be throwing a NullPointerException or FileNotFoundException and you want to track it down. Rather than go to the line of code and set a breakpoint, you can specify that the debugger should always stop when the exception occurs.
[Java Exception Breakpoint]
Step Filtering
“Step Into” is one of the most used feature while debugging the source code. Sometimes, it takes us through several stack traces to reach the code we want to debug. In such cases, “Step with Filters” functionality can help us. It simply filters out the classes that we don’t want to step into.
To specify which classes to filter out when “Step with Filters” is used, the preferences must be set. To activate the preferences panel choose Window > Preferences from the main window. Once there navigate to Java > Debug > Step Filtering and choose the classes/packages to be filtered out. When you step through the code, ensure that the “Use Step Filters” toggle button in Debug view is on.
[Step Filtering - Selecting Classes]
[Step Filtering - Activate Step Filtering]
Expression Evaluation
“Inspect” is a handy feature for evaluating your expressions. In the Debug perspective, select your expression, right click it and select “Inspect” from the menu to evaluate. You can do it by simply Ctrl+Shift+I key combination.
“Display View” is another efficient helper in evaluating expressions. Activate it from Window > Show View > Display, write your expressions to evaluate and execute them by right clicking and selecting “Display” from the context menu in the Debug perspective or simply by Ctrl+Shift+D shortcut. You can use code assist (Ctrl+Space) to compose your expressions.
The logical structure is very handy for examining things like maps and other java collections classes, instead of showing the full detail of all the internal variables the view will only show the “logical” pieces. It is activated/deactivated from “Variables” view using logical structure toggle button.
[Code Sample]
[Logical Structure - Deactivated]
[Logical Structure - Activated]
Conditional Debugging
Once you know where an error occurs, you will want to see what the program is doing right before it crashes. One way to do this is to step through every statement in the program, one at a time, until you reach the point of concern. Sometimes it’s better to just run a section of code and stop execution at that point so you can examine data at that location. It’s possible to declare conditional breakpoints triggered whenever the value of an expression changes. In addition, code assist is available when typing in the conditional expression.
Right click your breakpoint and select Breakpoint Properties… to set a condition. Check “Enable Condition” box and write your expression below it. You can define a “hit count” that stops your code after that count is reached if you want.
[Conditional Debugging]
Java Exception Breakpoint
Use “Java Exception Breakpoint” feature to track your exceptions more easily. For example, your program might be throwing a NullPointerException or FileNotFoundException and you want to track it down. Rather than go to the line of code and set a breakpoint, you can specify that the debugger should always stop when the exception occurs.
[Java Exception Breakpoint]
Step Filtering
“Step Into” is one of the most used feature while debugging the source code. Sometimes, it takes us through several stack traces to reach the code we want to debug. In such cases, “Step with Filters” functionality can help us. It simply filters out the classes that we don’t want to step into.
To specify which classes to filter out when “Step with Filters” is used, the preferences must be set. To activate the preferences panel choose Window > Preferences from the main window. Once there navigate to Java > Debug > Step Filtering and choose the classes/packages to be filtered out. When you step through the code, ensure that the “Use Step Filters” toggle button in Debug view is on.
[Step Filtering - Selecting Classes]
[Step Filtering - Activate Step Filtering]
Expression Evaluation
“Inspect” is a handy feature for evaluating your expressions. In the Debug perspective, select your expression, right click it and select “Inspect” from the menu to evaluate. You can do it by simply Ctrl+Shift+I key combination.
“Display View” is another efficient helper in evaluating expressions. Activate it from Window > Show View > Display, write your expressions to evaluate and execute them by right clicking and selecting “Display” from the context menu in the Debug perspective or simply by Ctrl+Shift+D shortcut. You can use code assist (Ctrl+Space) to compose your expressions.
发表评论
-
装饰模式与代理模式的区别(转载)
2013-04-22 11:28 580学习AOP时,教材上面都说使用的是动态代理,可是在印 ... -
《转》用JPDA轻松调试Java代码
2012-12-05 10:09 636在无法访问运行中的实例时,调试一个Java程序可能相当麻烦;当 ... -
《转》Java入门-高手对 CLASSPATH 的详解
2012-12-05 09:54 0Java入门-高手对 CLASSPATH 的详解 来源: 作者 ... -
java并发中Lock和Synchronized的异同
2011-11-27 14:15 7754java中可以使用Lock和Synchronized的可以实现 ... -
《转》再说final变量
2011-11-23 09:36 710再说final变量 分类: 【 ... -
<转>XFire生火指南(下)
2011-11-09 13:44 755<转>XFire生火指南(下) 请先阅读:XFi ... -
myeclipse7.0注册码算法
2011-09-19 21:25 799package com.edj.sessionbean; ... -
(转)cursor 与refcursor及sys_refcursor的区别
2011-09-14 08:56 0(转)cursor 与refcursor及sys_refcur ... -
BigDecimal不整除的一个异常
2011-09-13 09:37 2834BigDecimal不整除的一个异 ... -
(转)由MyEclipse内存不足谈谈JVM内存
2011-09-06 09:07 673原文出处: http://www.javatang.com/a ... -
Property文件的六种读取发放
2011-08-26 16:41 1071Java读取properties文件 【转】 使用J2SE ... -
tomcat端口被占用
2011-08-25 16:02 757关于tomcat端口占用的问题,怎么在myeclipse中启动 ... -
java中标签跳转
2011-08-23 14:02 994continue语句 1.continue语句用来结束本次 ... -
java一些书籍
2011-08-23 08:56 740深入理解java虚拟机 第二版 深入理解Java虚拟机:JVM ... -
主从表中从主表保存修改的子表
2011-08-22 18:09 1099我们从数据库中查出主表Class,连带它的子表Set<S ... -
java序列化深度克隆
2011-08-18 09:24 758publicObject copy() throwsI ...
相关推荐
Eclipse 的 Debug 介绍与技巧
eclipse中debug技巧,实用技巧。
Eclipse调试Debug的常用技巧,所有的调试方式.
Eclipse的Debug调试技巧大全,希望对大家有用,
Eclipse 调试器; Debug 视图;调试 Java 语言程序;远程调试;Eclipse快捷键调试
Eclipse_debug技
eclipse debug 调试技巧入门 基本够用
在Eclipse中使用debug(Eclipse调试常用技巧)
Eclipse Debug 调试技巧入门
该文档韵涵eclipse调试的很多技术,不会调式的可以进去看看,高手请飘过
NULL 博文链接:https://gdmao.iteye.com/blog/1159580
在Eclipse中使用debug(Eclipse调试常用技巧)
eclipse debug (调试) 技巧
java的调试技巧,应该很实用的,主要是针对Eclipse的操作讲述,讲述了多种调试技巧
主要介绍了Eclipse的Debug调试技巧大全(总结),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
eclipse 的高级debug 技巧总结
从零开始,教授如何配置 Eclipse 开发 SAP ABAP 程序环境。2020 年最新版本操作...ABAP Development Tool的Java端实现就是Eclipse的一个扩展,使用JCO(Java Connector)连接ABAP后台的adt服务,实现对ABAP程序的操作。
用于eclipse工具的优化,为方便程序员开发过程不收工具影响
详细介绍Eclipse调试技巧:该调试器提供所有标准调试功能,包括进行单步执行、设置断点和值、检查变量和值以及暂挂和恢复线程的能力。这篇文章主要讲述Eclipse调试器,包括Debug视图,断点的设置。