[infer][Java] change the models to add the file attribute to this instead of a field

master
jrm 10 years ago
parent d77b94c13d
commit 6a36b9f70c

@ -30,7 +30,7 @@ public class TypedArray {
public void recycle() { public void recycle() {
// Release resource // Release resource
if (mLength > 0) { if (mLength > 0) {
InferBuiltins.__set_mem_attribute(this.mValue); InferBuiltins.__set_mem_attribute(this);
} }
} }
@ -42,7 +42,7 @@ public class TypedArray {
// Acquire resource // Acquire resource
if (mLength > 0) { if (mLength > 0) {
InferBuiltins.__set_file_attribute(this.mValue); InferBuiltins.__set_file_attribute(this);
} }
} }

@ -20,29 +20,11 @@ import android.database.Cursor;
import com.facebook.infer.models.InferBuiltins; import com.facebook.infer.models.InferBuiltins;
import com.facebook.infer.models.InferUndefined; import com.facebook.infer.models.InferUndefined;
import java.util.Map;
public class SQLiteCursor extends Cursor { public class SQLiteCursor extends Cursor {
static final String TAG = "SQLiteCursor";
static int NO_COUNT;
private String mEditTable; private String mEditTable;
private String[] mColumns;
private SQLiteQuery mQuery;
private SQLiteCursorDriver mDriver;
private int mCount = NO_COUNT;
private int mCursorWindowCapacity;
private Map<String, Integer> mColumnNameMap;
private Throwable mStackTrace;
@Deprecated @Deprecated
public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
String editTable, SQLiteQuery query) { String editTable, SQLiteQuery query) {

@ -10,17 +10,10 @@ import java.nio.channels.FileChannel;
public class FileOutputStream extends OutputStream { public class FileOutputStream extends OutputStream {
private FileDescriptor fd; private FileDescriptor fd;
private boolean shouldClose;
private FileChannel channel; private FileChannel channel;
private int mode;
private CloseGuard guard;
private void init() { private void init() {
this.guard = new CloseGuard(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(this.guard);
} }
public FileOutputStream(String name) throws FileNotFoundException { public FileOutputStream(String name) throws FileNotFoundException {
@ -78,7 +71,7 @@ public class FileOutputStream extends OutputStream {
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(this.guard); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -5,8 +5,6 @@ import com.facebook.infer.models.InferUndefined;
public class PipedInputStream extends InputStream { public class PipedInputStream extends InputStream {
private Thread lastReader;
public PipedInputStream(PipedOutputStream src) throws IOException { public PipedInputStream(PipedOutputStream src) throws IOException {
this(); this();
} }
@ -17,8 +15,7 @@ public class PipedInputStream extends InputStream {
} }
public PipedInputStream() { public PipedInputStream() {
lastReader = new Thread(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(lastReader);
} }
public PipedInputStream(int pipeSize) { public PipedInputStream(int pipeSize) {
@ -26,7 +23,7 @@ public class PipedInputStream extends InputStream {
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(lastReader); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -5,20 +5,17 @@ import com.facebook.infer.models.InferUndefined;
public class PipedOutputStream extends OutputStream { public class PipedOutputStream extends OutputStream {
private PipedInputStream target;
public PipedOutputStream(PipedInputStream snk) throws IOException { public PipedOutputStream(PipedInputStream snk) throws IOException {
this.target = snk; InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(target);
} }
public PipedOutputStream() { public PipedOutputStream() {
this.target = new PipedInputStream(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(target);
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(target); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -5,16 +5,9 @@ import com.facebook.infer.models.InferUndefined;
public class PipedReader extends Reader { public class PipedReader extends Reader {
private Thread lastReader;
private Thread lastWriter;
private boolean isClosed;
private void init() throws IOException { private void init() throws IOException {
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
this.lastReader = new Thread(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(this.lastReader);
} }
public PipedReader() { public PipedReader() {
@ -60,7 +53,7 @@ public class PipedReader extends Reader {
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(this.lastReader); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -5,13 +5,9 @@ import com.facebook.infer.models.InferUndefined;
public abstract class PipedWriter extends Writer { public abstract class PipedWriter extends Writer {
private PipedReader destination;
private boolean isClosed;
private void init() throws IOException { private void init() throws IOException {
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
this.destination = new PipedReader(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(this.destination);
} }
public PipedWriter() { public PipedWriter() {
@ -66,7 +62,7 @@ public abstract class PipedWriter extends Writer {
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(this.destination); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -10,24 +10,17 @@ import java.nio.channels.FileChannel;
public class RandomAccessFile implements Closeable { public class RandomAccessFile implements Closeable {
private FileDescriptor fd; private FileDescriptor fd;
private boolean syncMetadata;
private FileChannel channel; private FileChannel channel;
private int mode;
private CloseGuard guard;
private byte[] scratch;
public RandomAccessFile(String name, String mode) public RandomAccessFile(String name, String mode)
throws FileNotFoundException { throws FileNotFoundException {
this.guard = new CloseGuard(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(this.guard);
} }
public RandomAccessFile(File file, String mode) public RandomAccessFile(File file, String mode)
throws FileNotFoundException { throws FileNotFoundException {
this.guard = new CloseGuard(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(this.guard);
} }
public FileChannel getChannel() { public FileChannel getChannel() {
@ -36,7 +29,7 @@ public class RandomAccessFile implements Closeable {
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(this.guard); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -1,111 +1,15 @@
package java.net; package java.net;
import com.facebook.infer.models.InferBuiltins; import com.facebook.infer.models.InferBuiltins;
public class HttpURLConnection extends URLConnection { 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) { public HttpURLConnection(URL url) {
super(url); super(url);
method = new String(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(method);
} }
public void disconnect() { public void disconnect() {
InferBuiltins.__set_mem_attribute(method); InferBuiltins.__set_mem_attribute(this);
} }
} }

@ -35,21 +35,9 @@ import java.io.OutputStream;
class PlainSocketImpl extends SocketImpl { 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() { PlainSocketImpl() {
guard = new CloseGuard(); InferBuiltins.__set_file_attribute(this);
InferBuiltins.__set_file_attribute(guard);
} }
@ -101,7 +89,7 @@ class PlainSocketImpl extends SocketImpl {
} }
protected void close() throws IOException { protected void close() throws IOException {
InferBuiltins.__set_mem_attribute(guard); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -10,34 +10,18 @@ import java.util.LinkedHashMap;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
public class ZipFile { 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<String, ZipEntry> entries;
private String comment;
private CloseGuard guard;
public ZipFile(String name) throws IOException { public ZipFile(String name) throws IOException {
this.filename = new String();
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
//Had to throw before setting attribute else //Had to throw before setting attribute else
// whenInferRunsOnJarFileClosedThenResourceLeakIsNotFound fails // whenInferRunsOnJarFileClosedThenResourceLeakIsNotFound fails
InferBuiltins.__set_file_attribute(this.filename); InferBuiltins.__set_file_attribute(this);
} }
public ZipFile(File file, int mode) throws IOException { public ZipFile(File file, int mode) throws IOException {
this.filename = new String();
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
InferBuiltins.__set_file_attribute(this.filename); InferBuiltins.__set_file_attribute(this);
} }
public ZipFile(File file) throws ZipException, IOException { public ZipFile(File file) throws ZipException, IOException {
@ -65,7 +49,7 @@ public class ZipFile {
} }
public void close() throws IOException { public void close() throws IOException {
InferBuiltins.__set_mem_attribute(this.filename); InferBuiltins.__set_mem_attribute(this);
InferUndefined.can_throw_ioexception_void(); InferUndefined.can_throw_ioexception_void();
} }

@ -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; package javax.net.ssl;
import com.facebook.infer.models.InferBuiltins; import com.facebook.infer.models.InferBuiltins;
@ -32,10 +7,6 @@ import java.net.URL;
public class HttpsURLConnection extends HttpURLConnection { public class HttpsURLConnection extends HttpURLConnection {
protected HostnameVerifier hostnameVerifier;
private SSLSocketFactory sslSocketFactory;
/** /**
* Creates an <code>HttpsURLConnection</code> using the * Creates an <code>HttpsURLConnection</code> using the
* URL specified. * URL specified.
@ -47,7 +18,7 @@ public class HttpsURLConnection extends HttpURLConnection {
} }
public void disconnect() { public void disconnect() {
InferBuiltins.__set_mem_attribute(method); InferBuiltins.__set_mem_attribute(this);
} }
} }

Loading…
Cancel
Save