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

java.lang.classfile.BufWriter should specify @throws for its writeXXX methods

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 23
    • core-libs
    • None
    • behavioral
    • minimal
    • Adding documentation tags into a preview API does not represent any compatibility risk.
    • Java API
    • SE

    Description

      Summary

      java.lang.classfile.BufWriter methods are missing some @throws doc annotations.

      Problem

      java.lang.classfile.BufWriter methods are missing some @throws doc annotations.

      Solution

      Add missing @throws tags to the BufWriter documentation.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/classfile/BufWriter.java b/src/java.base/share/classes/java/lang/classfile/BufWriter.java
      index bab8ebda4b87c..f178b6b2db0f6 100644
      --- a/src/java.base/share/classes/java/lang/classfile/BufWriter.java
      +++ b/src/java.base/share/classes/java/lang/classfile/BufWriter.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -124,6 +124,7 @@ public sealed interface BufWriter
            * @param arr the byte array
            * @param start the offset within the byte array of the range
            * @param length the length of the range
      +     * @throws IndexOutOfBoundsException if range is outside of the array bounds
            */
           void writeBytes(byte[] arr, int start, int length);
      
      @@ -134,6 +135,7 @@ public sealed interface BufWriter
            * @param offset the offset at which to patch
            * @param size the size of the integer value being written, in bytes
            * @param value the integer value
      +     * @throws IndexOutOfBoundsException if patched int is outside of bounds
            */
           void patchInt(int offset, int size, int value);
      
      @@ -152,7 +154,7 @@ public sealed interface BufWriter
            * to the buffer
            *
            * @param entry the constant pool entry
      -     * @throws NullPointerException if the entry is null
      +     * @throws IllegalArgumentException if the entry has invalid index
            */
           void writeIndex(PoolEntry entry);
      
      @@ -161,6 +163,7 @@ public sealed interface BufWriter
            * to the buffer, or zero if the entry is null
            *
            * @param entry the constant pool entry
      +     * @throws IllegalArgumentException if the entry has invalid index
            */
           void writeIndexOrZero(PoolEntry entry);
      
      @@ -180,6 +183,7 @@ public sealed interface BufWriter
            * entry in the list.
            *
            * @param list the list of entries
      +     * @throws IllegalArgumentException if any entry has invalid index
            */
           void writeListIndices(List<? extends PoolEntry> list);
      
      @@ -199,6 +203,7 @@ public sealed interface BufWriter
            * @param array the byte array
            * @param bufferOffset the offset into the array at which to write the
            *                     contents of the buffer
      +     * @throws IndexOutOfBoundsException if copying outside of the array bounds
            */
           void copyTo(byte[] array, int bufferOffset);
       }

      Attachments

        Issue Links

          Activity

            People

              asotona Adam Sotona
              asotona Adam Sotona
              Joe Darcy
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: