How to determine if a incoming request body contains java serialized object?

I am developing a burp extension which should be able to identify if the incoming request is gzip encoded or in java serialized form.

I am able to determine if that is in gzip format but facing difficulties in determining if it is a serailized object.

I have used the following code snippet but that does not seem to work.

 public  boolean isJavaSerialized(Object in) {
        ObjectInputStream fis;
        try {
            fis = new ObjectInputStream((InputStream) in);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            stderr.println("Marker3: "+ e.toString());

            return false;
        return true;

Please help