OSDN Git Service

ART: Remove Security initialization cutout
authorAndreas Gampe <agampe@google.com>
Sat, 16 Apr 2016 04:21:38 +0000 (21:21 -0700)
committerAndreas Gampe <agampe@google.com>
Wed, 20 Apr 2016 00:41:37 +0000 (17:41 -0700)
Change c94eeebc7cf3e577eed3ea380401007aea642bf3 introduced general
support for getResourceAsStream. Remove the specialized cutout.

Bug: 27265238

(cherry picked from commit 0f9b07f9781a064cbd59afbce3a03e8ae07a3117)

Change-Id: I3aad0053199809e11de4eed8ee6aac53346d3d22

runtime/interpreter/unstarted_runtime.cc
runtime/interpreter/unstarted_runtime_list.h

index a2a190e..5de0863 100644 (file)
@@ -1000,112 +1000,6 @@ void UnstartedRuntime::UnstartedMemoryPeekByteArray(
   UnstartedMemoryPeekArray(Primitive::kPrimByte, self, shadow_frame, arg_offset);
 }
 
-// This allows reading security.properties in an unstarted runtime and initialize Security.
-void UnstartedRuntime::UnstartedSecurityGetSecurityPropertiesReader(
-    Thread* self, ShadowFrame* shadow_frame ATTRIBUTE_UNUSED, JValue* result,
-    size_t arg_offset ATTRIBUTE_UNUSED) {
-  Runtime* runtime = Runtime::Current();
-
-  std::vector<std::string> split;
-  Split(runtime->GetBootClassPathString(), ':', &split);
-  if (split.empty()) {
-    AbortTransactionOrFail(self,
-                           "Boot classpath not set or split error:: %s",
-                           runtime->GetBootClassPathString().c_str());
-    return;
-  }
-  const std::string& source = split[0];
-
-  mirror::String* string_data;
-
-  // Use a block to enclose the I/O and MemMap code so buffers are released early.
-  {
-    std::string error_msg;
-    std::unique_ptr<ZipArchive> zip_archive(ZipArchive::Open(source.c_str(), &error_msg));
-    if (zip_archive.get() == nullptr) {
-      AbortTransactionOrFail(self,
-                             "Could not open zip file %s: %s",
-                             source.c_str(),
-                             error_msg.c_str());
-      return;
-    }
-    std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find("java/security/security.properties",
-                                                          &error_msg));
-    if (zip_entry.get() == nullptr) {
-      AbortTransactionOrFail(self,
-                             "Could not find security.properties file in %s: %s",
-                             source.c_str(),
-                             error_msg.c_str());
-      return;
-    }
-    std::unique_ptr<MemMap> map(zip_entry->ExtractToMemMap(source.c_str(),
-                                                           "java/security/security.properties",
-                                                           &error_msg));
-    if (map.get() == nullptr) {
-      AbortTransactionOrFail(self,
-                             "Could not unzip security.properties file in %s: %s",
-                             source.c_str(),
-                             error_msg.c_str());
-      return;
-    }
-
-    uint32_t length = zip_entry->GetUncompressedLength();
-    std::unique_ptr<char[]> tmp(new char[length + 1]);
-    memcpy(tmp.get(), map->Begin(), length);
-    tmp.get()[length] = 0;  // null terminator
-
-    string_data = mirror::String::AllocFromModifiedUtf8(self, tmp.get());
-  }
-
-  if (string_data == nullptr) {
-    AbortTransactionOrFail(self, "Could not create string from file content of %s", source.c_str());
-    return;
-  }
-
-  // Create a StringReader.
-  StackHandleScope<3> hs(self);
-  Handle<mirror::String> h_string(hs.NewHandle(string_data));
-
-  Handle<mirror::Class> h_class(hs.NewHandle(
-      runtime->GetClassLinker()->FindClass(self,
-                                           "Ljava/io/StringReader;",
-                                           ScopedNullHandle<mirror::ClassLoader>())));
-  if (h_class.Get() == nullptr) {
-    AbortTransactionOrFail(self, "Could not find StringReader class");
-    return;
-  }
-
-  if (!runtime->GetClassLinker()->EnsureInitialized(self, h_class, true, true)) {
-    AbortTransactionOrFail(self, "Could not initialize StringReader class");
-    return;
-  }
-
-  Handle<mirror::Object> h_obj(hs.NewHandle(h_class->AllocObject(self)));
-  if (h_obj.Get() == nullptr) {
-    AbortTransactionOrFail(self, "Could not allocate StringReader object");
-    return;
-  }
-
-  auto* cl = Runtime::Current()->GetClassLinker();
-  ArtMethod* constructor = h_class->FindDeclaredDirectMethod(
-      "<init>", "(Ljava/lang/String;)V", cl->GetImagePointerSize());
-  if (constructor == nullptr) {
-    AbortTransactionOrFail(self, "Could not find StringReader constructor");
-    return;
-  }
-
-  uint32_t args[1];
-  args[0] = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(h_string.Get()));
-  EnterInterpreterFromInvoke(self, constructor, h_obj.Get(), args, nullptr);
-
-  if (self->IsExceptionPending()) {
-    AbortTransactionOrFail(self, "Could not run StringReader constructor");
-    return;
-  }
-
-  result->SetL(h_obj.Get());
-}
-
 // This allows reading the new style of String objects during compilation.
 void UnstartedRuntime::UnstartedStringGetCharsNoCheck(
     Thread* self, ShadowFrame* shadow_frame, JValue* result ATTRIBUTE_UNUSED, size_t arg_offset) {
index be881cd..63425c0 100644 (file)
@@ -52,7 +52,6 @@
   V(MemoryPeekByteArray, "void libcore.io.Memory.peekByteArray(long, byte[], int, int)") \
   V(ReferenceGetReferent, "java.lang.Object java.lang.ref.Reference.getReferent()") \
   V(RuntimeAvailableProcessors, "int java.lang.Runtime.availableProcessors()") \
-  V(SecurityGetSecurityPropertiesReader, "java.io.Reader java.security.Security.getSecurityPropertiesReader()") \
   V(StringGetCharsNoCheck, "void java.lang.String.getCharsNoCheck(int, int, char[], int)") \
   V(StringCharAt, "char java.lang.String.charAt(int)") \
   V(StringSetCharAt, "void java.lang.String.setCharAt(int, char)") \