langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
changeset 1260 a772ba9ba43d
parent 939 38e24969c7e9
child 2513 1cbbf23b22f9
equal deleted inserted replaced
1259:61142e0aeb3f 1260:a772ba9ba43d
   120     Symtab syms;
   120     Symtab syms;
   121 
   121 
   122     Types types;
   122     Types types;
   123 
   123 
   124     /** The name table. */
   124     /** The name table. */
   125     final Name.Table names;
   125     final Names names;
   126 
   126 
   127     /** Force a completion failure on this name
   127     /** Force a completion failure on this name
   128      */
   128      */
   129     final Name completionFailureName;
   129     final Name completionFailureName;
   130 
   130 
   218      *  definitive classreader for this invocation.
   218      *  definitive classreader for this invocation.
   219      */
   219      */
   220     protected ClassReader(Context context, boolean definitive) {
   220     protected ClassReader(Context context, boolean definitive) {
   221         if (definitive) context.put(classReaderKey, this);
   221         if (definitive) context.put(classReaderKey, this);
   222 
   222 
   223         names = Name.Table.instance(context);
   223         names = Names.instance(context);
   224         syms = Symtab.instance(context);
   224         syms = Symtab.instance(context);
   225         types = Types.instance(context);
   225         types = Types.instance(context);
   226         fileManager = context.get(JavaFileManager.class);
   226         fileManager = context.get(JavaFileManager.class);
   227         if (fileManager == null)
   227         if (fileManager == null)
   228             throw new AssertionError("FileManager initialization error");
   228             throw new AssertionError("FileManager initialization error");
   513      */
   513      */
   514     byte[] signature;
   514     byte[] signature;
   515     int sigp;
   515     int sigp;
   516     int siglimit;
   516     int siglimit;
   517     boolean sigEnterPhase = false;
   517     boolean sigEnterPhase = false;
   518 
       
   519     /** Convert signature to type, where signature is a name.
       
   520      */
       
   521     Type sigToType(Name sig) {
       
   522         return sig == null
       
   523             ? null
       
   524             : sigToType(sig.table.names, sig.index, sig.len);
       
   525     }
       
   526 
   518 
   527     /** Convert signature to type, where signature is a byte array segment.
   519     /** Convert signature to type, where signature is a byte array segment.
   528      */
   520      */
   529     Type sigToType(byte[] sig, int offset, int len) {
   521     Type sigToType(byte[] sig, int offset, int len) {
   530         signature = sig;
   522         signature = sig;
   737         List<Type> tail = head;
   729         List<Type> tail = head;
   738         while (signature[sigp] != terminator)
   730         while (signature[sigp] != terminator)
   739             tail = tail.setTail(List.of(sigToType()));
   731             tail = tail.setTail(List.of(sigToType()));
   740         sigp++;
   732         sigp++;
   741         return head.tail;
   733         return head.tail;
   742     }
       
   743 
       
   744     /** Convert signature to type parameters, where signature is a name.
       
   745      */
       
   746     List<Type> sigToTypeParams(Name name) {
       
   747         return sigToTypeParams(name.table.names, name.index, name.len);
       
   748     }
   734     }
   749 
   735 
   750     /** Convert signature to type parameters, where signature is a byte
   736     /** Convert signature to type parameters, where signature is a byte
   751      *  array segment.
   737      *  array segment.
   752      */
   738      */
   950         if (nt != null && m == null)
   936         if (nt != null && m == null)
   951             throw badClassFile("bad.enclosing.method", self);
   937             throw badClassFile("bad.enclosing.method", self);
   952 
   938 
   953         self.name = simpleBinaryName(self.flatname, c.flatname) ;
   939         self.name = simpleBinaryName(self.flatname, c.flatname) ;
   954         self.owner = m != null ? m : c;
   940         self.owner = m != null ? m : c;
   955         if (self.name.len == 0)
   941         if (self.name.isEmpty())
   956             self.fullname = null;
   942             self.fullname = null;
   957         else
   943         else
   958             self.fullname = ClassSymbol.formFullName(self.name, self.owner);
   944             self.fullname = ClassSymbol.formFullName(self.name, self.owner);
   959 
   945 
   960         if (m != null) {
   946         if (m != null) {
  1498         Type type = readType(nextChar());
  1484         Type type = readType(nextChar());
  1499         if (name == names.init && currentOwner.hasOuterInstance()) {
  1485         if (name == names.init && currentOwner.hasOuterInstance()) {
  1500             // Sometimes anonymous classes don't have an outer
  1486             // Sometimes anonymous classes don't have an outer
  1501             // instance, however, there is no reliable way to tell so
  1487             // instance, however, there is no reliable way to tell so
  1502             // we never strip this$n
  1488             // we never strip this$n
  1503             if (currentOwner.name.len != 0)
  1489             if (!currentOwner.name.isEmpty())
  1504                 type = new MethodType(type.getParameterTypes().tail,
  1490                 type = new MethodType(type.getParameterTypes().tail,
  1505                                       type.getReturnType(),
  1491                                       type.getReturnType(),
  1506                                       type.getThrownTypes(),
  1492                                       type.getThrownTypes(),
  1507                                       syms.methodClass);
  1493                                       syms.methodClass);
  1508         }
  1494         }