• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Trying to extend an already extened class

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to create my own version the GZIPInputStream class to override what might possibly be this program, error messsage Corrupt GZIP trailer, web references at very bottom, and when i try to extend this class i'm getting an error in the following statement:

super(in, new Inflater(true), size)

$ javac MyGZIPInputStream.java
MyGZIPInputStream.java:56: cannot resolve symbol
symbol : constructor GZIPInputStream (java.io.InputStream,java.util.zip.Inflater,int)
location: class java.util.zip.GZIPInputStream
super(in, new Inflater(true), size);
^

Here is the original GZIPInputStream class and it is already extending the InflaterInputStream class, so what i'm wondering is when i try to extend the GZIPInputStream class, i am extending and already extended class, so
does that mean that the 'super' is now the old GZIPInputStream class?



Here are some references to that error message:

http://www.sanger.ac.uk/Software/Artemis/artemis_docs/uk.ac.sanger.pathogens.WorkingGZIPInputStream.html

http://www.aoindustries.com/docs/aocode-public/com/aoindustries/util/zip/CorrectedGZIPInputStream.html
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"super()" always refers to the immediate superclass. Your class's constructor has to invoke one of the existing GZIPInputStream constructors -- either

GZIPInputStream(InputStream in)

or

GZIPInputStream(InputStream in, int size)

The one you're trying to call is in InflaterInputStream, the "grandparent," and is therefore not accessible to your subclass. You want to use

super(in, size);

and forget about the Inflater -- the GZIPInputStream constructor will create one and pass it to InflaterInputStream when it, in turn, calls super() on its parent. Get it?
 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ernest!

Really appreciate the help again! have a great week!

bc
 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again Ernest!

I think there might be a 'bug' in the GZIPInputStream pgm, because when i use the following override fix program from Sanger labs, my SAX parse validation works fine!

And actually, the GZIPInputStream works fine for files under 300million or so, but over that it runs into the 'Corrupt Trailer' message!

By the way, I got this override pgm from one of the references in the previous post!

//package uk.ac.sanger.artemis.util;

import java.io.*;

/**
* A wrapper class to work around a bug in GZIPInputStream. The read()
* method sometimes throws a IOException complaining about a Corrupt GZIP
* trailer on the jdk 1.1.8-13 on the Alphas. This wrapper catches and
* ignores that exception.
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: WorkingGZIPInputStream.java,v 1.1 2004/06/09 09:53:17 tjc Exp $
**/

public class WorkingGZIPInputStream extends java.util.zip.GZIPInputStream {
/**
* Creates a new input stream with the specified buffer size.
* @param in the input stream
* @param size the input buffer size
* @exception IOException if an I/O error has occurred
**/

public WorkingGZIPInputStream (InputStream in, int size)
throws IOException {
super (in, size);
}

/**
* Creates a new input stream with a default buffer size.
* @param in the input stream
* @exception IOException if an I/O error has occurred
**/
public WorkingGZIPInputStream (InputStream in)
throws IOException {
super (in);
}

/**
* Calls super.read() and then catch and ignore any IOExceptions that
* mention "Corrupt GZIP trailer".
**/
public int read (byte buf[], int off, int len)
throws IOException {
try {
return super.read (buf, off, len);
} catch (IOException e) {
if (e.getMessage ().indexOf ("Corrupt GZIP trailer") != -1) {
return -1;
} else {
throw e;
}
}
}
}

Thanks again Ernest!
 
Replace the word "snake" with "danger noodle" in all tiny ads.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic