From 1065be328680167264a4a3cf025cb7e499b14a35 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Fri, 10 Feb 2017 13:59:04 -0800 Subject: [PATCH] [infer][java] Simplify some of the models of Java resources [4/n] Reviewed By: sblackshear Differential Revision: D4542437 fbshipit-source-id: 018cbf8 --- .../java/src/java/io/FilterOutputStream.java | 10 +++---- .../src/java/util/jar/JarOutputStream.java | 26 ++++++++++--------- .../src/java/util/zip/ZipOutputStream.java | 15 +---------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/infer/models/java/src/java/io/FilterOutputStream.java b/infer/models/java/src/java/io/FilterOutputStream.java index 154a3739c..a9c0eba91 100644 --- a/infer/models/java/src/java/io/FilterOutputStream.java +++ b/infer/models/java/src/java/io/FilterOutputStream.java @@ -11,7 +11,7 @@ package java.io; import com.facebook.infer.builtins.InferUndefined; -public class FilterOutputStream extends OutputStream { +public class FilterOutputStream { protected OutputStream out; @@ -19,16 +19,12 @@ public class FilterOutputStream extends OutputStream { } public FilterOutputStream(OutputStream out) { - this.out = out; + this.out = out; } public void close() throws IOException { if (out != null) { - if (out instanceof FileOutputStream) { - ((FileOutputStream) out).close(); - } else { - out.close(); - } + out.close(); } } diff --git a/infer/models/java/src/java/util/jar/JarOutputStream.java b/infer/models/java/src/java/util/jar/JarOutputStream.java index 2fdd28818..66b6b999c 100644 --- a/infer/models/java/src/java/util/jar/JarOutputStream.java +++ b/infer/models/java/src/java/util/jar/JarOutputStream.java @@ -9,6 +9,7 @@ package java.util.jar; +import com.facebook.infer.builtins.InferBuiltins; import com.facebook.infer.builtins.InferUndefined; import java.io.IOException; @@ -16,20 +17,21 @@ import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -public class JarOutputStream extends ZipOutputStream { - public JarOutputStream(OutputStream out, Manifest man) throws IOException { - super(out); - InferUndefined.can_throw_ioexception_void(); - } +public class JarOutputStream { - public JarOutputStream(OutputStream out) throws IOException { - super(out); - InferUndefined.can_throw_ioexception_void(); - } + public JarOutputStream(OutputStream out, Manifest man) throws IOException { + this(out); + } - public void putNextEntry(ZipEntry ze) throws IOException { - InferUndefined.can_throw_ioexception_void(); - } + public JarOutputStream(OutputStream out) throws IOException { + InferUndefined.can_throw_ioexception_void(); + InferBuiltins.__set_mem_attribute(out); + InferBuiltins.__set_file_attribute(this); + } + + public void putNextEntry(ZipEntry ze) throws IOException { + InferUndefined.can_throw_ioexception_void(); + } } diff --git a/infer/models/java/src/java/util/zip/ZipOutputStream.java b/infer/models/java/src/java/util/zip/ZipOutputStream.java index 47662c56e..9445e4ee9 100644 --- a/infer/models/java/src/java/util/zip/ZipOutputStream.java +++ b/infer/models/java/src/java/util/zip/ZipOutputStream.java @@ -17,11 +17,7 @@ import java.io.OutputStream; import com.facebook.infer.builtins.InferUndefined; -public class ZipOutputStream extends DeflaterOutputStream { - - public ZipOutputStream(OutputStream out) { - super(out); - } +public class ZipOutputStream { public void putNextEntry(ZipEntry e) throws IOException { InferUndefined.can_throw_ioexception_void(); @@ -31,13 +27,4 @@ public class ZipOutputStream extends DeflaterOutputStream { InferUndefined.can_throw_ioexception_void(); } - public void close() throws IOException { - if (out != null) { - if (out instanceof FileOutputStream) { - ((FileOutputStream) out).close(); - } else if (out instanceof BufferedOutputStream) { - ((BufferedOutputStream) out).close(); - } - } - } }