From 9fc2e9c965c68d56a0caf812f7f6d38d15317063 Mon Sep 17 00:00:00 2001 From: Bjorn Bringert Date: Thu, 28 May 2009 14:48:32 +0100 Subject: [PATCH] MemoryFile constructor and native methods throw IOExceptions. These native methods in android.os.MemoryFile throw IOException but their Java declarations did not include "throws IOException": native_open(),native_mmap(),native_read(),native_write(),native_pin() The MemoryFile(String,int) constructor calls native_open and native_mmap, but does not declare that it throws IOException. The other Java methods that call the native methods do actually declare that they throw IOException. This means that any code that created memory files could throw an IOException, without knowing about it. This changes adds "throws IOException" to the native methods and to the constructor. The constructor change changes the public API, but maintains binary compatibility. There is some precedent for making source incompatible source API changes for this sort of thing (see https://mondrian.corp.google.com/changelist/124214-p9). The change also makes the native methods static, which they seem to have been intended to be, as indicated by the second parameter to the native implementations being named "clazz". This requires changes to the Compatibility Test Suite to catch the exceptions. This is done in https://android-git.corp.google.com/g/2617 Unfortunately that change must be submitted together with this one in order not to break the build. Fixes http://b/issue?id=1881829 --- api/current.xml | 2 ++ core/java/android/os/MemoryFile.java | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/api/current.xml b/api/current.xml index bf3044e30fce3..c67c9c4218597 100644 --- a/api/current.xml +++ b/api/current.xml @@ -93802,6 +93802,8 @@ + +