Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6265127

Bridge methods lead to confusing stack traces

    Details

    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      generic
    • OS:
      generic

      Description

      Stack traces from bridge methods are confusing:

      $ /usr/java/jdk1.6.0/bin/javac -fullversion
      javac full version "1.6.0-ea-b33"
      $ /usr/java/jdk1.6.0/bin/javac Bridge.java
      $ /usr/java/jdk1.6.0/bin/java Bridge
      Exception in thread "main" java.lang.Error
              at Bridge.getName(Bridge.java:10)
              at Bridge.getName(Bridge.java:5)
              at Bridge.main(Bridge.java:7)
      $ cat -n Bridge.java
           1 interface Foo {
           2 CharSequence getName();
           3 }
           4
           5 public class Bridge implements Foo {
           6 public static void main(String... args) {
           7 ((Foo)new Bridge()).getName();
           8 }
           9 public String getName() {
          10 throw new Error();
          11 }
          12 }
      $

      In this example, the confusing stack trace is:
              at Bridge.getName(Bridge.java:5)

      Perhaps this would be less confusing if the position
      of the method declaration is used (line 9 in this example).

      ###@###.### 2005-05-04 08:41:06 GMT

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ahe Peter Ahe
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: