Bug in encoding type annotations for supertype_targets

Joel Borggrén-Franck joel.borggren.franck at gmail.com
Thu Jan 28 18:45:05 UTC 2016


While working on the core reflection code for type annotation I
discovered what I believe is a javac bug. It looks like javac omits
the type_path structure for nested types in supertype and implemets
targets. In the example below, when looking at GenericSub in javap I
get this encoding of @Foo:

  0: #18(): CLASS_EXTENDS, type_index=-1, location=[TYPE_ARGUMENT(0)]

as expected, but when looking at either Impl or SubInner I get:

  0: #15(): CLASS_EXTENDS, type_index=0


  0: #14(): CLASS_EXTENDS, type_index=-1

Note the missing type_path (location in javap) for the nesting, which
I think table Table in the vm spec implies.

I can file a bug if you want me to.


--- 8< ---

import java.lang.annotation.*;
import java.util.*;
import java.lang.reflect.*;

 * @test
public class LostTypePath {}

class Super {}
class Sub extends @Foo Super {}

class Generic<A> {}
class GenericSub<B> extends Generic<@Foo B> {}

class Outer { public static class Inner {}}
class SubInner extends Outer . @Foo Inner {}

interface IOuter { public interface IInner {}}
class Impl implements IOuter . @Foo IInner {}

@interface Foo {}

More information about the compiler-dev mailing list