< prev index next >

src/java.base/share/classes/sun/reflect/generics/scope/ClassScope.java

Print this page




  56         Constructor<?> cnstr = receiver.getEnclosingConstructor();
  57         if (cnstr != null)
  58             // Receiver is a local or anonymous class enclosed in a
  59             // constructor.
  60             return ConstructorScope.make(cnstr);
  61 
  62         Class<?> c = receiver.getEnclosingClass();
  63         // if there is a declaring class, recvr is a member class
  64         // and its enclosing scope is that of the declaring class
  65         if (c != null)
  66             // Receiver is a local class, an anonymous class, or a
  67             // member class (static or not).
  68             return ClassScope.make(c);
  69 
  70         // otherwise, recvr is a top level class, and it has no real
  71         // enclosing scope.
  72         return DummyScope.make();
  73     }
  74 
  75     /**
  76      * Factory method. Takes a <tt>Class</tt> object and creates a
  77      * scope for it.
  78      * @param c - a Class whose scope we want to obtain
  79      * @return The type-variable scope for the class c
  80      */
  81     public static ClassScope make(Class<?> c) { return new ClassScope(c);}
  82 
  83 }


  56         Constructor<?> cnstr = receiver.getEnclosingConstructor();
  57         if (cnstr != null)
  58             // Receiver is a local or anonymous class enclosed in a
  59             // constructor.
  60             return ConstructorScope.make(cnstr);
  61 
  62         Class<?> c = receiver.getEnclosingClass();
  63         // if there is a declaring class, recvr is a member class
  64         // and its enclosing scope is that of the declaring class
  65         if (c != null)
  66             // Receiver is a local class, an anonymous class, or a
  67             // member class (static or not).
  68             return ClassScope.make(c);
  69 
  70         // otherwise, recvr is a top level class, and it has no real
  71         // enclosing scope.
  72         return DummyScope.make();
  73     }
  74 
  75     /**
  76      * Factory method. Takes a {@code Class} object and creates a
  77      * scope for it.
  78      * @param c - a Class whose scope we want to obtain
  79      * @return The type-variable scope for the class c
  80      */
  81     public static ClassScope make(Class<?> c) { return new ClassScope(c);}
  82 
  83 }
< prev index next >