Bug 427075 - [1.8] Unable to set breakpoint in interface methods
Summary: [1.8] Unable to set breakpoint in interface methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 421806
  Show dependency tree
 
Reported: 2014-01-31 01:16 EST by Noopur Gupta CLA
Modified: 2014-04-03 08:57 EDT (History)
4 users (show)

See Also:
Michael_Rennie: review+


Attachments
BP in interface methods (1.65 KB, image/png)
2014-01-31 01:16 EST, Noopur Gupta CLA
no flags Details
Allowing Method Breakpoints in interface (6.98 KB, patch)
2014-02-07 06:05 EST, Sarika Sinha CLA
no flags Details | Diff
Allowing Method Breakpoints in interface with Test Coverage (28.56 KB, patch)
2014-02-12 02:30 EST, Sarika Sinha CLA
no flags Details | Diff
Allowing Method Breakpoints in interface with Test Cases (27.45 KB, patch)
2014-02-12 02:52 EST, Sarika Sinha CLA
no flags Details | Diff
Allowing Method Breakpoints in interface with updated Test Cases (26.65 KB, patch)
2014-02-12 04:24 EST, Sarika Sinha CLA
no flags Details | Diff
Allowing Method Breakpoints in interface with Test Cases (26.65 KB, patch)
2014-02-13 00:08 EST, Sarika Sinha CLA
Michael_Rennie: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2014-01-31 01:16:10 EST
Created attachment 239501 [details]
BP in interface methods

interface I2 {
	default int m1() {
		int a = 1;
		return a + 2;
	}
	static void m2() {
		System.out.println("hi");
	}
}
---------------------------------------------
Try to add a breakpoint within the default/static method above.
We get the message as shown in the screenshot and the breakpoint is not added.
Comment 1 Sarika Sinha CLA 2014-02-07 06:05:21 EST
Created attachment 239730 [details]
Allowing Method Breakpoints in interface

This patch makes the breakpoints feasible for interface methods. The specific check to not allow the breakpoint on methods have been removed. Methods with code can have all breakpoints - entry/exit and method body.
Watchpoints are still not supported.
Comment 2 Michael Rennie CLA 2014-02-07 15:08:20 EST
(In reply to Sarika Sinha from comment #1)
> Created attachment 239730 [details]
> Allowing Method Breakpoints in interface
> 
> This patch makes the breakpoints feasible for interface methods. The
> specific check to not allow the breakpoint on methods have been removed.
> Methods with code can have all breakpoints - entry/exit and method body.
> Watchpoints are still not supported.

The patch works nicely.

Two nits:

1. can we get some test coverage for the new breakpoint locations?
2. can we update the failure message for a *normal* interface method? Currently it says 'Selection does not contain a method'. Better might be 'Cannot set a breakpoint on an unimplemented interface method'
Comment 3 Sarika Sinha CLA 2014-02-12 02:30:32 EST
Created attachment 239847 [details]
Allowing Method Breakpoints in interface with Test Coverage

Added test cases and the specific error message for Interface unimplemented method.
Comment 4 Sarika Sinha CLA 2014-02-12 02:52:21 EST
Created attachment 239848 [details]
Allowing Method Breakpoints in interface with Test Cases
Comment 5 Sarika Sinha CLA 2014-02-12 04:24:29 EST
Created attachment 239853 [details]
Allowing Method Breakpoints in interface with updated Test Cases

Updated testcase scenario to cover bug 427077
Comment 6 Michael Rennie CLA 2014-02-12 21:34:07 EST
Two of the new tests fail:

junit.framework.AssertionFailedError: Breakpoint not added
	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.Assert.assertFalse(Assert.java:39)
	at junit.framework.TestCase.assertFalse(TestCase.java:210)
	at org.eclipse.jdt.debug.tests.breakpoints.AbstractToggleBreakpointsTarget$Listener.getAdded(AbstractToggleBreakpointsTarget.java:69)
	at org.eclipse.jdt.debug.tests.breakpoints.TestToggleBreakpointsTarget8.testInterfaceDefaultMethodBreakpoint(TestToggleBreakpointsTarget8.java:45)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at org.eclipse.jdt.debug.tests.AbstractDebugTest.runBare(AbstractDebugTest.java:2441)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at org.eclipse.jdt.debug.tests.DebugSuite$1.run(DebugSuite.java:55)
	at java.lang.Thread.run(Thread.java:744)

and

junit.framework.AssertionFailedError: Should be a method breakpoint
	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.TestCase.assertTrue(TestCase.java:192)
	at org.eclipse.jdt.debug.tests.breakpoints.TestToggleBreakpointsTarget8.testInterfaceStaticMethodBreakpoint(TestToggleBreakpointsTarget8.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at org.eclipse.jdt.debug.tests.AbstractDebugTest.runBare(AbstractDebugTest.java:2441)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at org.eclipse.jdt.debug.tests.DebugSuite$1.run(DebugSuite.java:55)
	at java.lang.Thread.run(Thread.java:744)
Comment 7 Sarika Sinha CLA 2014-02-13 00:08:59 EST
Created attachment 239889 [details]
Allowing Method Breakpoints in interface with Test Cases

Oops, missed to update the line no after test file update.
Comment 9 Jay Arthanareeswaran CLA 2014-02-21 01:22:28 EST
Verified for Eclipse + Java 8 RC1 using Kepler SR2 +  
Eclipse Java Development Tools Patch for Java 8 Support (BETA)   
1.0.0.v20140220-2054