JDK-4798003 : SPEC: unspecified NegativeArraySizeException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Future Project
  • OS: generic
  • CPU: generic
  • Submitted: 2002-12-26
  • Updated: 2005-05-30
  • Resolved: 2005-01-22
Related Reports
Relates :  
Description

Name: dkR10031			Date: 12/26/2002



The current reference implementation (JDK 1.4.2beta, build b11)   
of the javax.sound.midi.SysexMessage.getData() throws unspecified 
NegativeArraySizeException. This behavior seems quite reasonable 
but is not specified:
------------------ example code begin --------------------------
import javax.sound.midi.SysexMessage;
class MySysexMessageExtention extends SysexMessage {
    MySysexMessageExtention(byte[] data) {
        super(data);
    }
}
public class MySysexMessage{
    public static void main(String args[]) {
        try {
            MySysexMessageExtention mySME = new MySysexMessageExtention(null);
            mySME.getData();
        } catch (Exception e) {
            System.out.println("Exception: " + e);
        }
    }
}
------------------ example code end ----------------------------
------------------ log begin -----------------------------------
bash-2.03$ uname -a
SunOS novo101 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-1
bash-2.03$ /export/ld25/java/dest/jdk1.4.2-b11/solaris-sparc/bin/java -showversion MySysexMessage
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b11)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b11, mixed mode)

Exception: java.lang.NegativeArraySizeException
------------------ log end -------------------------------------

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
14-06-2004

PUBLIC COMMENTS SPEC: unspecified NegativeArraySizeException
10-06-2004

EVALUATION ###@###.### 2003-01-09 Not sure if all those misuse cases need to be documented. Commit to tiger. ###@###.### 2003-10-10 Passing null to the protected constructor messes up the internal state of SysexMessage. That's why the exception occures on calling getData(). So the solution should be: 1. Specify that null is not allowed as parameter in SysexMessage(byte[] data). The specification already says "data - an array of bytes containing the complete message." The MIDI standard specifies that a valid sysex message contains at least 3 bytes. If this is followed to, it should be clear that passing null is not allowed. But ok, be explicit :) 2. Change the implementation is some way to reject null as a parameter. This should be done consistently for all subclasses of MidiMessage (ShortMessage, MetaMessage, SysexMessage). ###@###.### 2003-10-10 If we decide to throw NPE, which sounds reasonable, then it will go along with 4912693: Specify default behavior for null arguments. Therefore committing to next release.
10-10-2003