4

This simple example demonstrates the problem:

public class Main {
    interface Person {
        default int amountOfHands() {
            return 2;
        }
    }

    public static class BasicPerson implements Person {

        int numberOfFaces() {
            return 1;
        }
    }

    public static void main(String[] args) {
        System.out.println("Put a breakpoint here");
    }
}

I ran this code in IntelliJ IDEA in debug mode and put two watches in the main method:

new BasicPerson().amountOfHands();

new BasicPerson().numberOfFaces();

Both methods should return a primitive int, however only the second watch (class method) shows a primitive int, when the first one (default interface method) shows a boxed Integer object.

Watches

Why is that? Is that a bug?

jmj
  • 237,923
  • 42
  • 401
  • 438
gvlasov
  • 18,638
  • 21
  • 74
  • 110

1 Answers1

4

I suppose it's a bug in IntelliJ IDEA. In Eclipse both expressions are evaluated to primitive values as expected.

Tagir Valeev
  • 97,161
  • 19
  • 222
  • 334