390 // x = new Type(arg) { subclass body ... } |
390 // x = new Type(arg) { subclass body ... } |
391 Identifier superName = FieldExpression.toIdentifier(type); |
391 Identifier superName = FieldExpression.toIdentifier(type); |
392 if (superName == null) { |
392 if (superName == null) { |
393 env.error(type.getWhere(), "type.expected"); |
393 env.error(type.getWhere(), "type.expected"); |
394 } |
394 } |
395 Vector ext = new Vector(1); |
395 Vector<IdentifierToken> ext = new Vector<>(1); |
396 Vector impl = new Vector(0); |
396 Vector<IdentifierToken> impl = new Vector<>(0); |
397 ext.addElement(new IdentifierToken(idNull)); |
397 ext.addElement(new IdentifierToken(idNull)); |
398 if (token == IMPLEMENTS || token == EXTENDS) { |
398 if (token == IMPLEMENTS || token == EXTENDS) { |
399 env.error(pos, "anonymous.extends"); |
399 env.error(pos, "anonymous.extends"); |
400 parseInheritance(ext, impl); // error recovery |
400 parseInheritance(ext, impl); // error recovery |
401 } |
401 } |
1680 t = Type.tMethod(t, atypes); |
1680 t = Type.tMethod(t, atypes); |
1681 |
1681 |
1682 // Parse and ignore throws clause |
1682 // Parse and ignore throws clause |
1683 IdentifierToken exp[] = null; |
1683 IdentifierToken exp[] = null; |
1684 if (token == THROWS) { |
1684 if (token == THROWS) { |
1685 Vector v = new Vector(); |
1685 Vector<IdentifierToken> v = new Vector<>(); |
1686 scan(); |
1686 scan(); |
1687 v.addElement(parseName(false)); |
1687 v.addElement(parseName(false)); |
1688 while (token == COMMA) { |
1688 while (token == COMMA) { |
1689 scan(); |
1689 scan(); |
1690 v.addElement(parseName(false)); |
1690 v.addElement(parseName(false)); |
1888 // Parse the class name |
1888 // Parse the class name |
1889 IdentifierToken nm = scanner.getIdToken(); |
1889 IdentifierToken nm = scanner.getIdToken(); |
1890 long p = pos; |
1890 long p = pos; |
1891 expect(IDENT); |
1891 expect(IDENT); |
1892 |
1892 |
1893 Vector ext = new Vector(); |
1893 Vector<IdentifierToken> ext = new Vector<>(); |
1894 Vector impl = new Vector(); |
1894 Vector<IdentifierToken> impl = new Vector<>(); |
1895 parseInheritance(ext, impl); |
1895 parseInheritance(ext, impl); |
1896 |
1896 |
1897 ClassDefinition tmp = parseClassBody(nm, mod, ctx, doc, ext, impl, p); |
1897 ClassDefinition tmp = parseClassBody(nm, mod, ctx, doc, ext, impl, p); |
1898 |
1898 |
1899 FPstate = oldFPstate; |
1899 FPstate = oldFPstate; |
1900 |
1900 |
1901 return tmp; |
1901 return tmp; |
1902 } |
1902 } |
1903 |
1903 |
1904 protected void parseInheritance(Vector ext, Vector impl) throws SyntaxError, IOException { |
1904 protected void parseInheritance(Vector<IdentifierToken> ext, Vector<IdentifierToken> impl) throws SyntaxError, IOException { |
1905 // Parse extends clause |
1905 // Parse extends clause |
1906 if (token == EXTENDS) { |
1906 if (token == EXTENDS) { |
1907 scan(); |
1907 scan(); |
1908 ext.addElement(parseName(false)); |
1908 ext.addElement(parseName(false)); |
1909 while (token == COMMA) { |
1909 while (token == COMMA) { |
1927 * Parse the body of a class or interface declaration, |
1927 * Parse the body of a class or interface declaration, |
1928 * starting at the left brace. |
1928 * starting at the left brace. |
1929 */ |
1929 */ |
1930 protected ClassDefinition parseClassBody(IdentifierToken nm, int mod, |
1930 protected ClassDefinition parseClassBody(IdentifierToken nm, int mod, |
1931 int ctx, String doc, |
1931 int ctx, String doc, |
1932 Vector ext, Vector impl, long p |
1932 Vector<IdentifierToken> ext, Vector<IdentifierToken> impl, long p |
1933 ) throws SyntaxError, IOException { |
1933 ) throws SyntaxError, IOException { |
1934 // Decide which is the super class |
1934 // Decide which is the super class |
1935 IdentifierToken sup = null; |
1935 IdentifierToken sup = null; |
1936 if ((mod & M_INTERFACE) != 0) { |
1936 if ((mod & M_INTERFACE) != 0) { |
1937 if (impl.size() > 0) { |
1937 if (impl.size() > 0) { |
1938 env.error(((IdentifierToken)impl.elementAt(0)).getWhere(), |
1938 env.error(impl.elementAt(0).getWhere(), |
1939 "intf.impl.intf"); |
1939 "intf.impl.intf"); |
1940 } |
1940 } |
1941 impl = ext; |
1941 impl = ext; |
1942 } else { |
1942 } else { |
1943 if (ext.size() > 0) { |
1943 if (ext.size() > 0) { |
1944 if (ext.size() > 1) { |
1944 if (ext.size() > 1) { |
1945 env.error(((IdentifierToken)ext.elementAt(1)).getWhere(), |
1945 env.error(ext.elementAt(1).getWhere(), |
1946 "multiple.inherit"); |
1946 "multiple.inherit"); |
1947 } |
1947 } |
1948 sup = (IdentifierToken)ext.elementAt(0); |
1948 sup = ext.elementAt(0); |
1949 } |
1949 } |
1950 } |
1950 } |
1951 |
1951 |
1952 ClassDefinition oldClass = curClass; |
1952 ClassDefinition oldClass = curClass; |
1953 |
1953 |