How does setting breakpoints in Java work?

Is it just based on the source file name and line number? Does the class or method name also figure in?

If I have an old version of the source in my debugger and set a breakpoint, the cursor is off when I step through. How far off can it be? Can it go into the wrong method (or even the wrong class if there are more than one class in that file)?

What happens when there are multiple classes of the same name in the JVM (could happen if you have more than one classloader)? Do they all get the breakpoint?

In a web application container, can I set breakpoints for just one web application (and not the others)?

How much of this is IDE specific and how much is determined by the debugging interface that the JVM provides? For example: In Eclipse I can set conditional breakpoints based on the values of variables. Is that just filtering done by Eclipse on an unconditional breakpoint in the JVM?

解决方案

There are different kind of breakpoints. Some breakpoints are line-based, some are not. How this affects your actual debugging depends on what your IDE actually does. For example, in Eclipse, if you add a breakpoint in the middle of a method, that will be a line-based breakpoint. If you add a breakpoint on a line containing the signature of a method, that will be a method entry breakpoint.

If the source code you're looking at is not the exact source of the class that is running, a line breakpoint won't be mapped onto the right line of course. So java might not stop at the line you intended, and your IDE indeed could be showing you the wrong method or even wrong class.

But a method entry breakpoint will still work (stop at the right moment), even if the line on which the method was defined has changed; but again an IDE might show the wrong line in the debugger.

(And there are other kind of events/breakpoints too, like class loading,... You could take a look at the subinterfaces of EventRequest if you want to know more about the internals).

To answer your other question: breakpoints apply to all classloaders in the JVM.

java设置断点,在Java中设置断点相关推荐

  1. LoadRunner中Action的迭代次数的设置和运行场景中设置

    LoadRunner中Action的迭代次数的设置和运行场景中设置 LoadRunner是怎么重复迭代和怎么增加并发运行的呢? 另外,在参数化时,对于一次压力测试中均只能用一次的资源应该怎么参数化呢? ...

  2. java placeholder_java – 如何在JTextfield中设置像Placeholder一样的文本

    我用来覆盖文本字段绘制方法,直到我最终得到更多的自定义文本字段然后我真的想- 然后我发现this prompt API易于使用,不需要你扩展任何组件.它还有一个很好的"伙伴"API ...

  3. android 动态设置margin,android 代码中设置margin

    场景:Android怎么在java代码中设置margin Android如何在java代码中设置margin 原创帖,转发请注明出处:http://thierry-xing.iteye.com/blo ...

  4. Linux下设置时区(通过shell设置和程序中设置)及程序中设置环境变量

    Shell中设置 bash中   export TZ="Europe/Moscow"        date -u -s "2011-10-29 21:55:00&quo ...

  5. 1、代码中设置编码、编辑器中设置Python的编码

    1Python中文编码 1.1代码中设置编码 Python中默认的编码格式是ASCII格式,在没有修改编码格式时无法正确打印汉字,所以在读取中文的时候会报错. 解决办法为只要在文件开头加入 # -- ...

  6. python字典怎么设置_在python中设置字典中的属性

    在python中设置字典中的属性 是否可以在python中从字典创建一个对象,使每个键都是该对象的属性? 像这样的东西: d = { 'name': 'Oscar', 'lastName': 'Rey ...

  7. python设置http代理_python中设置HTTP代理的方法

    什么是HTTP代理 HTTP代理本质上是一个Web应用,它和其他普通Web应用没有根本区别.HTTP代理收到请求后,根据Header中Host字段的主机名和Get/POST请求地址综合判断目标主机,建 ...

  8. php中date设置北京时区,PHP中设置时区方法小结

    PHP代码中的时间判断语句出了点问题,问题出在PHP的时区设置上,PHP所取的时间默认是格林威治标准时间,所以和北京时间相差8小时.找到原因后,在网上搜索到了一些关于PHP的时区设置方法:1.修改ph ...

  9. html设置单词间隔,css中设置英文单词之间间距的属性是什么

    css中设置英文单词之间间距的属性是word-spacing.word-spacing属性可以增加或减少字与字之间的空白,如[p{word-spacing:30px;}]. 本文操作环境:window ...

  10. android 在代码中设置样式,安卓代码中设置fontFamily中的样式

    今天和视觉调样式的时候,发现一个问题,我们代码中经常使用fontFamily的样式,比如: android:id="@+id/name" android:layout_width= ...

最新文章

  1. cxgrid中纵横单元格合并_被合并单元格折磨疯的我,真后悔没早点知道这个Excel技巧!...
  2. python box2d_win10+Anaconda3成功使用pip安装Box2d
  3. Shiro <shiro:hasPermission >标签不生效,shiro权限不生效原因
  4. linux 特定用户ssh,linux - 如何在登录后将SSH用户限制为一组预定义的命令?
  5. python传文件给java_用java pyhont通过HTTP协议传输文件流
  6. cpprestsdk编译安装linux,使用C++ REST SDK开发简单的Web(HTTP)服务
  7. (转)ASP.NET中常见文件类型及用途
  8. ArchLinux安装简单安装教程
  9. Java基础教程【第二章:Java数据类型和变量】
  10. 自己学java需要多久_自学 java, 学多久可以自己找到工作?
  11. Oracle数据库安装及配置
  12. JDK1.8中文帮助文档下载
  13. 毕设--基于51单片机数字电压表的设计
  14. 希尔密码_密码学中的希尔密码
  15. 编程英语(单词有音标)
  16. 地址总线是单向还是双向_大余双向钢塑土工格栅%/*的作用泰安恒大工程材料-老友网...
  17. 64位windows系统的PatchGuard
  18. **Gcc编译器报错:gcc -m32报错**
  19. php 保持内容换行符,PHP 将内容写入word pdf 换行符不生效咋办
  20. 单片机c语言篮球比分_单片机和C语言的篮球计时计分器设计

热门文章

  1. Account detail页面加载的性能分析 - 2017-09-25
  2. notes belonging to given user
  3. Equipment download和自动生成的IBASE DB 信息
  4. No authorization to log on as a Trusted System
  5. Trial SCN WebIDE版本下载
  6. SAP CRM my task 6个roundtrip的原理讲解
  7. 计算机应用技术备选计划方案,华东理工大学博士研究生培养方案计算机应用技术、计算机软件与理论、计算机系统结构二级学科(学科代码:081203、081202、081201)信息科学与工程学院...
  8. echarts 堆叠柱状图3d效果_【python可视化】:pyecharts:柱形图、堆叠条形图、极坐标堆叠柱形图、极坐标堆叠分类条形图...
  9. 电脑卡顿不流畅怎么解决_电脑用久了卡怎么办?学会这四招解决你的电脑卡顿问题...
  10. cassandra本地连接失败_无法连接到本地Cassandra实例?