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

remove uses of anachronistic array declarations for method return type

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
    • Resolved In Build:
      b11

      Description

      According to JLS 8.4, a if a method's return type is an array type, the bracket pairs can be placed after the formal parameters. That section of the JLS says, "This syntax is supported for compatibility with early versions of the Java programming language. It is very strongly recommended that this syntax is not used in new code." This usage occurs in several places in the JDK. They should be cleaned up. A partial list is as follows:

      src/java.base/share/classes/java/io/ByteArrayOutputStream.java: public synchronized byte toByteArray()[] {
      src/java.base/share/classes/java/io/CharArrayWriter.java: public char toCharArray()[] {
      src/java.base/share/classes/sun/text/CompactByteArray.java: public short getIndexArray()[]
      src/java.base/share/classes/sun/text/CompactByteArray.java: public byte getStringArray()[]
      src/java.desktop/share/classes/javax/swing/text/html/parser/Entity.java: public char getData()[]
      src/jdk.rmic/share/classes/sun/tools/java/BinaryAttribute.java: public byte getData()[] { return data; }
      src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java: public byte getAttribute(Identifier name)[] {
      src/jdk.rmic/share/classes/sun/tools/java/BinaryCode.java: public BinaryExceptionHandler getExceptionHandlers()[] {
      src/jdk.rmic/share/classes/sun/tools/java/BinaryCode.java: public byte getCode()[] { return code; }
      src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java: public final ClassDeclaration getInterfaces()[] {
      src/jdk.rmic/share/classes/sun/tools/java/MethodType.java: public Type getArgumentTypes()[] {
      src/jdk.rmic/share/classes/sun/tools/java/Parser.java: protected final Expression exprArgs(int index)[] {
      src/jdk.rmic/share/classes/sun/tools/java/Parser.java: protected final Statement statArgs(int index)[] {
      src/jdk.rmic/share/classes/sun/tools/java/Parser.java: // Parse optional array sepecifier, ie: foo()[][]
      src/jdk.rmic/share/classes/sun/tools/java/Type.java: public Type getArgumentTypes()[] {

        Attachments

          Activity

            People

            • Assignee:
              smarks Stuart Marks
              Reporter:
              smarks Stuart Marks
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: