Loading ...
Sorry, an error occurred while loading the content.
 

Re: [jsyn] VoiceAllocator Compiler Exception

Expand Messages
  • Phil Burk
    Hello Daniel, ... This is a new error that I haven t seen before. I don t know why IBM gave that compile-time error. Maybe because VoiceAllocator constructor
    Message 1 of 5 , Jan 2, 2002
      Hello Daniel,

      > but its strange that javac allows the code below, then throws a runtime
      > error, while jikes (IBM's compiler - which seems generally to follow the
      > compiler spec more closely) won't compile the code. Any thoughts?

      This is a new error that I haven't seen before.

      I don't know why IBM gave that compile-time error. Maybe because
      VoiceAllocator constructor does not throw SynthException but
      BussedVoiceAllocator does. I will try with Jikes to see if I can reproduce
      it.

      Q1) When you get the run-time error, are you using the SUN JVM or an IBM
      JVM?

      Q2) When you get the run-time error, have you already executed
      Synth.startEngine() successfully?

      I just realized that BussedVoiceAllocator does not have a constructor that
      takes a synthContext!

      Q3) Did you create a unique SynthContext, or are you using the global
      SynthContext? Here are the two way to start up:

      /* Create a unique SynthContext so that this Applet cannot interfere with
      other Applets. */
      synthContext = new SynthContext();
      synthContext.startEngine( 0 );

      versus

      Synth.startEngine( 0 ); // creates a global context

      The NullPointerException could be because JSyn is trying to access a global
      context when there is none.

      Phil Burk
    • daniel
      Hey All, I think this is likely a simple problem (I m just starting out w JSyn), but its strange that javac allows the code below, then throws a runtime
      Message 2 of 5 , Jan 3, 2002
        Hey All,
        I think this is likely a simple problem (I'm just starting out w' JSyn),
        but its strange that javac allows the code below, then throws a runtime
        error, while jikes (IBM's compiler - which seems generally to follow the
        compiler spec more closely) won't compile the code. Any thoughts?

        CODE: (from within try block)
        ---------------------------------
        BussedVoiceAllocator allocator = new BussedVoiceAllocator( 4 ) {
        public SynthCircuit makeVoice() throws SynthException
        {
        SynthNote circ = new RingModBell();
        return addVoiceToMix( circ );
        }
        };

        COMPILER ERROR (jikes)
        ---------------------------------
        Found 1 semantic error compiling
        "C:/Docs/java/dch/jmsl/SynthNoteTest.java":

        <-------------------------------
        21. BussedVoiceAllocator allocator = new BussedVoiceAllocator(
        4 ) {
        . . .
        27. };
        ------>
        *** Error: A constructor associated with this anonymous type does not
        throw the exception "com/softsynth/jsyn/SynthException" thrown by its
        super type, "com/softsynth/jsyn/util/BussedVoiceAllocator".

        RUNTIME ERROR (after compiling w' javac)
        ---------------------------------
        java.lang.NullPointerException
        at com.softsynth.jsyn.SynthObject.<init>(Unknown Source)
        at com.softsynth.jsyn.SynthSound.<init>(Unknown Source)
        at com.softsynth.jsyn.SynthUnit.<init>(Unknown Source)
        at com.softsynth.jsyn.BusReader.<init>(Unknown Source)
        at com.softsynth.jsyn.BusReader.<init>(Unknown Source)
        at com.softsynth.jsyn.util.BussedVoiceAllocator.<init>(Unknown
        Source)
        at SynthNoteTest$1.<init>(SynthNoteTest.java:22)
        at SynthNoteTest.test(SynthNoteTest.java:21)
        at SynthNoteTest.main(SynthNoteTest.java:14)

        Thanks very much,
        -daniel
      • Phil Burk
        Hello Daniel, Hmmm. I think you are right about it being illegal to throw new Exceptions from an overriden method. My Java book (Arnold and Gosling) says: The
        Message 3 of 5 , Jan 3, 2002
          Hello Daniel,

          Hmmm. I think you are right about it being illegal to throw new Exceptions
          from an overriden method. My Java book (Arnold and Gosling) says:

          "The overriding method's throws clause can be different from the throws
          clause of the superclass's method as long as the throws clause doesn't
          declare any types not covered in the original method definition."

          I wonder why J++ and the JDK let me get away with it. Luckily SynthException
          is now a RuntimeException so I can just remove all the throws declarations.
          SynthException only gets thrown if something terrible and unexpected happens
          in the native engine like outOfMemory.

          Phil Burk

          > compile (with jikes). I think you're correct about the compile-time error
          being
          > caused by the different signatures in the two constructors. I'm not sure
          its
          > 'legal' to override a method(or constructor) w'out keeping the return type
          &
          > exceptions the same, or maybe you can remove exceptions, but not add new
          ones -
          > can't remember.
        • daniel
          Phil, Thanks for the reply. Checking first for a valid context via Synth.getSharedContext() solves the NullPointerException, but I still can t compile (with
          Message 4 of 5 , Jan 3, 2002
            Phil,
            Thanks for the reply. Checking first for a valid context via
            Synth.getSharedContext() solves the NullPointerException, but I still can't
            compile (with jikes). I think you're correct about the compile-time error being
            caused by the different signatures in the two constructors. I'm not sure its
            'legal' to override a method(or constructor) w'out keeping the return type &
            exceptions the same, or maybe you can remove exceptions, but not add new ones -
            can't remember... Anyhow, one workaround(which satisifies jikes) is to subclass
            as follows:
            public abstract class MyBussedVoiceAllocator extends BussedVoiceAllocator {
            public MyBussedVoiceAllocator(int i) { super(i); }
            }
            Any other thoughts?
            Thanks much,
            -daniel

            Phil Burk wrote:

            > Hello Daniel,
            >
            > > but its strange that javac allows the code below, then throws a runtime
            > > error, while jikes (IBM's compiler - which seems generally to follow the
            > > compiler spec more closely) won't compile the code. Any thoughts?
            >
            > This is a new error that I haven't seen before.
            >
            > I don't know why IBM gave that compile-time error. Maybe because
            > VoiceAllocator constructor does not throw SynthException but
            > BussedVoiceAllocator does. I will try with Jikes to see if I can reproduce
            > it.
            >
            > Q1) When you get the run-time error, are you using the SUN JVM or an IBM
            > JVM?
            >
            > Q2) When you get the run-time error, have you already executed
            > Synth.startEngine() successfully?
            >
            > I just realized that BussedVoiceAllocator does not have a constructor that
            > takes a synthContext!
            >
            > Q3) Did you create a unique SynthContext, or are you using the global
            > SynthContext? Here are the two way to start up:
            >
            > /* Create a unique SynthContext so that this Applet cannot interfere with
            > other Applets. */
            > synthContext = new SynthContext();
            > synthContext.startEngine( 0 );
            >
            > versus
            >
            > Synth.startEngine( 0 ); // creates a global context
            >
            > The NullPointerException could be because JSyn is trying to access a global
            > context when there is none.
            >
            > Phil Burk
            >
            > JSyn home at: http://www.softsynth.com/jsyn/
            > List home at: http://groups.yahoo.com/group/jsyn/
            > To unsubscribe, send an email to: jsyn-unsubscribe@yahoogroups.com
            >
            >
            > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

            --


            --------------------------
            Daniel C. Howe
            University of Washington
            CSE/iSchool Ph.D
            dchowe@...
            ph# (212) 481.6405
            --------------------------
          • daniel
            Not sure about J++, but I ve noticed that the javac compiler, besides being awfully slow, doesn t follow the spec all that closely... Thanks again, -daniel ...
            Message 5 of 5 , Jan 3, 2002
              Not sure about J++, but I've noticed that the javac compiler, besides being
              awfully slow, doesn't follow the spec all that closely...
              Thanks again,
              -daniel

              Phil Burk wrote:

              > Hello Daniel,
              >
              > Hmmm. I think you are right about it being illegal to throw new Exceptions
              > from an overriden method. My Java book (Arnold and Gosling) says:
              >
              > "The overriding method's throws clause can be different from the throws
              > clause of the superclass's method as long as the throws clause doesn't
              > declare any types not covered in the original method definition."
              >
              > I wonder why J++ and the JDK let me get away with it. Luckily SynthException
              > is now a RuntimeException so I can just remove all the throws declarations.
              > SynthException only gets thrown if something terrible and unexpected happens
              > in the native engine like outOfMemory.
              >
              > Phil Burk
              >
              > > compile (with jikes). I think you're correct about the compile-time error
              > being
              > > caused by the different signatures in the two constructors. I'm not sure
              > its
              > > 'legal' to override a method(or constructor) w'out keeping the return type
              > &
              > > exceptions the same, or maybe you can remove exceptions, but not add new
              > ones -
              > > can't remember.
              >
              > JSyn home at: http://www.softsynth.com/jsyn/
              > List home at: http://groups.yahoo.com/group/jsyn/
              > To unsubscribe, send an email to: jsyn-unsubscribe@yahoogroups.com
              >
              >
              > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

              --


              --------------------------
              Daniel C. Howe
              University of Washington
              CSE/iSchool Ph.D
              dchowe@...
              ph# (212) 481.6405
              --------------------------
            Your message has been successfully submitted and would be delivered to recipients shortly.