Results 1 to 5 of 5
  1. #1
    Penny666 is offline Member
    Join Date
    Dec 2013
    Posts
    11
    Rep Power
    0

    Default Incompatible magic value 716570812

    Hiya,

    Does anyone know what the cause of the following is many thanks...

    Incompatible magic value 716570812

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Incompatible magic value 716570812

    That means that the class file does not contain the correct bytes for a class.
    The first 4 bytes of a class file in hex are: 0xcafe babe

    Open the class file in an editor and see what is in it.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Penny666 is offline Member
    Join Date
    Dec 2013
    Posts
    11
    Rep Power
    0

    Default Re: Incompatible magic value 716570812

    hiya,

    yes you are absolutely right. I have spent the last couple of hours getting to the bottom of this.

    Initially, I borrowed code from an example that used a byte array to read all bytes from the InputStream so that the certificate could be verified. I now realise that that code allowed the byte array to be overwritten a number of times to flush the InputStream. I changed my InputStream byte array reader to the following code and all certs are verified and all classes are now defined without errors.

    public static byte[] getBytesFromInputStream(InputStream is) throws IOException
    {
    long length=is.available();
    if(length>Integer.MAX_VALUE)throw new IOException("File too large");
    byte[] bytes=new byte[(int)length];
    int offset=0;
    int numRead=0;
    while(offset<bytes.length&&(numRead=is.read(bytes, offset,bytes.length-offset))>=0)offset+=numRead;
    if(offset<bytes.length)throw new IOException("File read error");
    is.close();
    return bytes;
    }

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Incompatible magic value 716570812

    I'm not sure that the available() method always returns the number of bytes that will be sent over a stream.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Penny666 is offline Member
    Join Date
    Dec 2013
    Posts
    11
    Rep Power
    0

    Default Re: Incompatible magic value 716570812

    Only if the extended class of the abstract class of InputStream doesn't override the method of available() in which case zero would be returned (as stated by the java docs)

    I tested the extended class of InputStream that JarFile.getInputStream() provides and it seems to work correctly. Thanks for the warning tho :)

Similar Threads

  1. Magic squares help
    By mjpam in forum New To Java
    Replies: 3
    Last Post: 06-30-2010, 03:24 PM
  2. Magic square
    By gandalf5166 in forum New To Java
    Replies: 20
    Last Post: 04-15-2010, 08:18 PM
  3. Magic Square!!!... :D
    By joms999 in forum New To Java
    Replies: 4
    Last Post: 02-25-2010, 08:55 AM
  4. Magic Eightball
    By sachmow in forum New To Java
    Replies: 1
    Last Post: 11-15-2009, 05:37 PM
  5. Incompatible magic value 1008821359
    By willemjav in forum Java Applets
    Replies: 2
    Last Post: 03-21-2008, 10:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •