4

In Oracle Javadocs for Java 8 it is specified that InterfaceType has a method named invokeMethod.

However when I check on my system I don't see any such method in the Interface:

kshitiz:/usr/lib/jvm/jdk1.8.0/lib$ javap -classpath tools.jar com.sun.jdi.InterfaceType
Compiled from "InterfaceType.java"
public interface com.sun.jdi.InterfaceType extends com.sun.jdi.ReferenceType {
  public abstract java.util.List<com.sun.jdi.InterfaceType> superinterfaces();
  public abstract java.util.List<com.sun.jdi.InterfaceType> subinterfaces();
  public abstract java.util.List<com.sun.jdi.ClassType> implementors();
}

Java version check:

kshitiz:/usr/lib/jvm/jdk1.8.0/lib$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

What am I missing?

Jon Heller
  • 34,999
  • 6
  • 74
  • 132
Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169

1 Answers1

2

After testing different versions it seems that Oracle has added the method in minor update u40. Versions below that don't have this method.

On JDK 1.8.0_40:

Compiled from "InterfaceType.java"
public interface com.sun.jdi.InterfaceType extends com.sun.jdi.ReferenceType {
  public abstract java.util.List<com.sun.jdi.InterfaceType> superinterfaces();
  public abstract java.util.List<com.sun.jdi.InterfaceType> subinterfaces();
  public abstract java.util.List<com.sun.jdi.ClassType> implementors();
  public com.sun.jdi.Value invokeMethod(com.sun.jdi.ThreadReference, com.sun.jdi.Method, java.util.List<? extends com.sun.jdi.Value>, int) throws com.sun.jdi.InvalidTypeException, com.sun.jdi.ClassNotLoadedException, com.sun.jdi.IncompatibleThreadStateException, com.sun.jdi.InvocationException;
}

I was surprised by this since such structural changes are supposed to happen only between major versions not between minor revisions. However com.sun packages are considered private Oracle API and subject to change anytime.

Community
  • 1
  • 1
Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169
  • I've got 1.8.0_45 and can see the method. – biziclop Jul 14 '15 at 20:29
  • 1
    @Kshitiz `com.sun` packages are allowed to change at any time; they're treated as private implementation details – Louis Wasserman Jul 14 '15 at 20:57
  • @LouisWasserman Do I have any references for that? I'm skeptical because there are plenty of third party debugging tools that rely on these packages. – Kshitiz Sharma Jul 14 '15 at 21:00
  • 1
    @KshitizSharma, just because people use something doesn't magically extend official API stability guarantees to those parts too. In fact, I did have observed debugging tools break on between java updates. – the8472 Jul 14 '15 at 21:33
  • 1
    @KshitizSharma See e.g. http://stackoverflow.com/questions/1834826/it-is-a-bad-practice-to-use-suns-proprietary-java-classes – Louis Wasserman Jul 14 '15 at 21:38
  • I concede. Updated my answer to reflect this. – Kshitiz Sharma Jul 14 '15 at 21:58
  • 3
    @Louis Wasserman: don’t mix up `sun.*` packages with `com.sun.*` packages. The latter contain some vendor specific APIs which are, well, just vendor specific, but not private. One example is the API discussed here, as the link in the question already shows, it’s a *documented* API. – Holger Jul 15 '15 at 07:47
  • 2
    @Kshitiz Sharma: it’s a `default` method which has been added, so it’s unlikely to break anything, but its absence in Java 8 has been considered a bug that must be fixed. See also http://stackoverflow.com/a/30038411/2711488 – Holger Jul 15 '15 at 08:01