Menu

ExpectJException visibility?

Help
2010-10-28
2013-05-23
  • Nickolas Moser

    Nickolas Moser - 2010-10-28

    I grabbed the src, bins, and javadoc directly, (not using maven) and have created an eclipse project that references the binaries. I attached the src/javadoc to that reference.  ExpectJ seems to import correctly, I can create an ExpectJ object (so I think the library is correctly referenced), but I see a visibility error on the ExpectJException constructor.   Code below.  Any thoughts?

    import expectj.ExpectJ; // OKAY, this imports successfully
    import expectj.AbstractSpawnable;
    import expectj.ExpectJException;
    // ...
    @override
    public int getExitValue() throws ExpectJException {
        // just placed here to show issue
        ExpectJ expectinator = new ExpectJ(5); //    OKAY!   ExpectJ is visible
           
        if (!this.isClosed()) {
            //    ERROR!   The constructor ExpectJException(String) is not visible
            throw new ExpectJException("\""+this.port+"\" is not closed");
        }
        return 0;
    }
    
     
  • Nickolas Moser

    Nickolas Moser - 2010-10-28

    Just a thought, the constructors for ExpectJException aren't specifically declared to be public… so according to http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html, their access level should be limited to the package. 

    This should probably be public, so folks can properly extend the AbstractSpawnable class (or implement the Spawnable interface).

     
  • Nickolas Moser

    Nickolas Moser - 2010-10-28

    Update: My previous reply is correct-I just regenerated the jar with that fix and sure enough, the error went away. 

    Was there a specific reason the ExpectJException constructors weren't declared public by default? 

    Also, for what it's worth, there was a feature request for serial support.  I was able to wrap the RxTx serial module using AbstractSpawnable so ExpectJ appears to work with serial.  By no means have I done extensive testing, but it seems promising as a Proof of Concept.  Maybe this should get incorporated into ExpectJ now….

     

Log in to post a comment.

MongoDB Logo MongoDB