diff --git a/infer/models/java/src/android/content/res/TypedArray.java b/infer/models/java/src/android/content/res/TypedArray.java index de869103b..31d8968a2 100644 --- a/infer/models/java/src/android/content/res/TypedArray.java +++ b/infer/models/java/src/android/content/res/TypedArray.java @@ -30,7 +30,7 @@ public class TypedArray { public void recycle() { // Release resource if (mLength > 0) { - InferBuiltins.__set_mem_attribute(this.mValue); + InferBuiltins.__set_mem_attribute(this); } } @@ -42,7 +42,7 @@ public class TypedArray { // Acquire resource if (mLength > 0) { - InferBuiltins.__set_file_attribute(this.mValue); + InferBuiltins.__set_file_attribute(this); } } diff --git a/infer/models/java/src/android/database/sqlite/SQLiteCursor.java b/infer/models/java/src/android/database/sqlite/SQLiteCursor.java index 2a86e3909..f974b7447 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteCursor.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteCursor.java @@ -20,29 +20,11 @@ import android.database.Cursor; import com.facebook.infer.models.InferBuiltins; import com.facebook.infer.models.InferUndefined; -import java.util.Map; - public class SQLiteCursor extends Cursor { - static final String TAG = "SQLiteCursor"; - static int NO_COUNT; private String mEditTable; - private String[] mColumns; - - private SQLiteQuery mQuery; - - private SQLiteCursorDriver mDriver; - - private int mCount = NO_COUNT; - - private int mCursorWindowCapacity; - - private Map mColumnNameMap; - - private Throwable mStackTrace; - @Deprecated public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { diff --git a/infer/models/java/src/java/io/FileOutputStream.java b/infer/models/java/src/java/io/FileOutputStream.java index d1e6eb991..1b0e8ac02 100644 --- a/infer/models/java/src/java/io/FileOutputStream.java +++ b/infer/models/java/src/java/io/FileOutputStream.java @@ -10,17 +10,10 @@ import java.nio.channels.FileChannel; public class FileOutputStream extends OutputStream { private FileDescriptor fd; - private boolean shouldClose; - private FileChannel channel; - private int mode; - - private CloseGuard guard; - private void init() { - this.guard = new CloseGuard(); - InferBuiltins.__set_file_attribute(this.guard); + InferBuiltins.__set_file_attribute(this); } public FileOutputStream(String name) throws FileNotFoundException { @@ -78,7 +71,7 @@ public class FileOutputStream extends OutputStream { } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this.guard); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/io/PipedInputStream.java b/infer/models/java/src/java/io/PipedInputStream.java index 0f4e334df..78ac3414c 100644 --- a/infer/models/java/src/java/io/PipedInputStream.java +++ b/infer/models/java/src/java/io/PipedInputStream.java @@ -5,8 +5,6 @@ import com.facebook.infer.models.InferUndefined; public class PipedInputStream extends InputStream { - private Thread lastReader; - public PipedInputStream(PipedOutputStream src) throws IOException { this(); } @@ -17,8 +15,7 @@ public class PipedInputStream extends InputStream { } public PipedInputStream() { - lastReader = new Thread(); - InferBuiltins.__set_file_attribute(lastReader); + InferBuiltins.__set_file_attribute(this); } public PipedInputStream(int pipeSize) { @@ -26,7 +23,7 @@ public class PipedInputStream extends InputStream { } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(lastReader); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/io/PipedOutputStream.java b/infer/models/java/src/java/io/PipedOutputStream.java index a95d7e654..23dff8b26 100644 --- a/infer/models/java/src/java/io/PipedOutputStream.java +++ b/infer/models/java/src/java/io/PipedOutputStream.java @@ -5,20 +5,17 @@ import com.facebook.infer.models.InferUndefined; public class PipedOutputStream extends OutputStream { - private PipedInputStream target; public PipedOutputStream(PipedInputStream snk) throws IOException { - this.target = snk; - InferBuiltins.__set_file_attribute(target); + InferBuiltins.__set_file_attribute(this); } public PipedOutputStream() { - this.target = new PipedInputStream(); - InferBuiltins.__set_file_attribute(target); + InferBuiltins.__set_file_attribute(this); } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(target); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/io/PipedReader.java b/infer/models/java/src/java/io/PipedReader.java index 166f12eaa..0a11bc09a 100644 --- a/infer/models/java/src/java/io/PipedReader.java +++ b/infer/models/java/src/java/io/PipedReader.java @@ -5,16 +5,9 @@ import com.facebook.infer.models.InferUndefined; public class PipedReader extends Reader { - private Thread lastReader; - - private Thread lastWriter; - - private boolean isClosed; - private void init() throws IOException { InferUndefined.can_throw_ioexception_void(); - this.lastReader = new Thread(); - InferBuiltins.__set_file_attribute(this.lastReader); + InferBuiltins.__set_file_attribute(this); } public PipedReader() { @@ -60,7 +53,7 @@ public class PipedReader extends Reader { } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this.lastReader); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/io/PipedWriter.java b/infer/models/java/src/java/io/PipedWriter.java index 05bb66934..1f1905632 100644 --- a/infer/models/java/src/java/io/PipedWriter.java +++ b/infer/models/java/src/java/io/PipedWriter.java @@ -5,13 +5,9 @@ import com.facebook.infer.models.InferUndefined; public abstract class PipedWriter extends Writer { - private PipedReader destination; - private boolean isClosed; - private void init() throws IOException { InferUndefined.can_throw_ioexception_void(); - this.destination = new PipedReader(); - InferBuiltins.__set_file_attribute(this.destination); + InferBuiltins.__set_file_attribute(this); } public PipedWriter() { @@ -66,7 +62,7 @@ public abstract class PipedWriter extends Writer { } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this.destination); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/io/RandomAccessFile.java b/infer/models/java/src/java/io/RandomAccessFile.java index d8f02ab78..a107a4e36 100644 --- a/infer/models/java/src/java/io/RandomAccessFile.java +++ b/infer/models/java/src/java/io/RandomAccessFile.java @@ -10,24 +10,17 @@ import java.nio.channels.FileChannel; public class RandomAccessFile implements Closeable { private FileDescriptor fd; - private boolean syncMetadata; private FileChannel channel; - private int mode; - private CloseGuard guard; - - private byte[] scratch; public RandomAccessFile(String name, String mode) throws FileNotFoundException { - this.guard = new CloseGuard(); - InferBuiltins.__set_file_attribute(this.guard); + InferBuiltins.__set_file_attribute(this); } public RandomAccessFile(File file, String mode) throws FileNotFoundException { - this.guard = new CloseGuard(); - InferBuiltins.__set_file_attribute(this.guard); + InferBuiltins.__set_file_attribute(this); } public FileChannel getChannel() { @@ -36,7 +29,7 @@ public class RandomAccessFile implements Closeable { } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this.guard); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/net/HttpURLConnection.java b/infer/models/java/src/java/net/HttpURLConnection.java index 3a95df8f9..2b870c38a 100644 --- a/infer/models/java/src/java/net/HttpURLConnection.java +++ b/infer/models/java/src/java/net/HttpURLConnection.java @@ -1,111 +1,15 @@ - - package java.net; import com.facebook.infer.models.InferBuiltins; public class HttpURLConnection extends URLConnection { - private static int DEFAULT_CHUNK_LENGTH; - - private static String[] PERMITTED_USER_METHODS; - - protected String method; - - protected int responseCode; - - protected String responseMessage; - - protected boolean instanceFollowRedirects; - - private static boolean followRedirects; - - protected int chunkLength; - - protected int fixedContentLength; - - protected long fixedContentLengthLong; - - public static int HTTP_ACCEPTED; - - public static int HTTP_BAD_GATEWAY; - - public static int HTTP_BAD_METHOD; - - public static int HTTP_BAD_REQUEST; - - public static int HTTP_CLIENT_TIMEOUT; - - public static int HTTP_CONFLICT; - - public static int HTTP_CREATED; - - public static int HTTP_ENTITY_TOO_LARGE; - - public static int HTTP_FORBIDDEN; - - public static int HTTP_GATEWAY_TIMEOUT; - - public static int HTTP_GONE; - - public static int HTTP_INTERNAL_ERROR; - - public static int HTTP_LENGTH_REQUIRED; - - public static int HTTP_MOVED_PERM; - - public static int HTTP_MOVED_TEMP; - - public static int HTTP_MULT_CHOICE; - - public static int HTTP_NO_CONTENT; - - public static int HTTP_NOT_ACCEPTABLE; - - public static int HTTP_NOT_AUTHORITATIVE; - - public static int HTTP_NOT_FOUND; - - public static int HTTP_NOT_IMPLEMENTED; - - public static int HTTP_NOT_MODIFIED; - - public static int HTTP_OK; - - public static int HTTP_PARTIAL; - - public static int HTTP_PAYMENT_REQUIRED; - - public static int HTTP_PRECON_FAILED; - - public static int HTTP_PROXY_AUTH; - - public static int HTTP_REQ_TOO_LONG; - - public static int HTTP_RESET; - - public static int HTTP_SEE_OTHER; - - public static int HTTP_SERVER_ERROR; - - public static int HTTP_USE_PROXY; - - public static int HTTP_UNAUTHORIZED; - - public static int HTTP_UNSUPPORTED_TYPE; - - public static int HTTP_UNAVAILABLE; - - public static int HTTP_VERSION; - public HttpURLConnection(URL url) { super(url); - method = new String(); - InferBuiltins.__set_file_attribute(method); + InferBuiltins.__set_file_attribute(this); } - public void disconnect() { - InferBuiltins.__set_mem_attribute(method); + InferBuiltins.__set_mem_attribute(this); } } diff --git a/infer/models/java/src/java/net/PlainSocketImpl.java b/infer/models/java/src/java/net/PlainSocketImpl.java index 978652e7e..a6a75471f 100644 --- a/infer/models/java/src/java/net/PlainSocketImpl.java +++ b/infer/models/java/src/java/net/PlainSocketImpl.java @@ -35,21 +35,9 @@ import java.io.OutputStream; class PlainSocketImpl extends SocketImpl { - private static InetAddress lastConnectedAddress; - - private static int lastConnectedPort; - - private boolean streaming = true; - - private boolean shutdownInput; - - private Proxy proxy; - - private CloseGuard guard; PlainSocketImpl() { - guard = new CloseGuard(); - InferBuiltins.__set_file_attribute(guard); + InferBuiltins.__set_file_attribute(this); } @@ -101,7 +89,7 @@ class PlainSocketImpl extends SocketImpl { } protected void close() throws IOException { - InferBuiltins.__set_mem_attribute(guard); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/java/util/zip/ZipFile.java b/infer/models/java/src/java/util/zip/ZipFile.java index d3c669f71..9c428b891 100644 --- a/infer/models/java/src/java/util/zip/ZipFile.java +++ b/infer/models/java/src/java/util/zip/ZipFile.java @@ -10,34 +10,18 @@ import java.util.LinkedHashMap; import java.util.NoSuchElementException; public class ZipFile { - static int GPBF_ENCRYPTED_FLAG; - static int GPBF_DATA_DESCRIPTOR_FLAG; - - static int GPBF_UTF8_FLAG; - static int GPBF_UNSUPPORTED_MASK; - public static int OPEN_READ; - public static int OPEN_DELETE; - - private String filename; - private File fileToDeleteOnClose; - private RandomAccessFile raf; - private LinkedHashMap entries; - private String comment; - private CloseGuard guard; public ZipFile(String name) throws IOException { - this.filename = new String(); InferUndefined.can_throw_ioexception_void(); //Had to throw before setting attribute else // whenInferRunsOnJarFileClosedThenResourceLeakIsNotFound fails - InferBuiltins.__set_file_attribute(this.filename); + InferBuiltins.__set_file_attribute(this); } public ZipFile(File file, int mode) throws IOException { - this.filename = new String(); InferUndefined.can_throw_ioexception_void(); - InferBuiltins.__set_file_attribute(this.filename); + InferBuiltins.__set_file_attribute(this); } public ZipFile(File file) throws ZipException, IOException { @@ -65,7 +49,7 @@ public class ZipFile { } public void close() throws IOException { - InferBuiltins.__set_mem_attribute(this.filename); + InferBuiltins.__set_mem_attribute(this); InferUndefined.can_throw_ioexception_void(); } diff --git a/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java b/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java index c19ba2e89..1e019e6e4 100644 --- a/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java +++ b/infer/models/java/src/javax/net/ssl/HttpsURLConnection.java @@ -1,28 +1,3 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - package javax.net.ssl; import com.facebook.infer.models.InferBuiltins; @@ -32,10 +7,6 @@ import java.net.URL; public class HttpsURLConnection extends HttpURLConnection { - protected HostnameVerifier hostnameVerifier; - - private SSLSocketFactory sslSocketFactory; - /** * Creates an HttpsURLConnection using the * URL specified. @@ -47,7 +18,7 @@ public class HttpsURLConnection extends HttpURLConnection { } public void disconnect() { - InferBuiltins.__set_mem_attribute(method); + InferBuiltins.__set_mem_attribute(this); } }