<commit_before>/* Copyright (c) 2008-2013, Avian Contributors

   Permission to use, copy, modify, and/or distribute this software
   for any purpose with or without fee is hereby granted, provided
   that the above copyright notice and this permission notice appear
   in all copies.

   There is NO WARRANTY for this software.  See license.txt for
   details. */

struct JavaVM;
struct _JNIEnv;

struct JniConstants {
  static void init(_JNIEnv* env);
};

extern "C" int JNI_OnLoad(JavaVM*, void*);

#define _POSIX_C_SOURCE 200112L
#undef _GNU_SOURCE
#include "avian/machine.h"
#include "avian/classpath-common.h"
#include "avian/process.h"
#include "avian/util.h"

#ifdef PLATFORM_WINDOWS
const char* getErrnoDescription(int err);		// This function is defined in mingw-extensions.cpp
#endif

using namespace vm;

extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_avian_Classes_defineVMClass
(Thread*, object, uintptr_t*);

namespace {

namespace local {

void*
getDirectBufferAddress(Thread* t, object b)
{
  PROTECT(t, b);

  object field = resolveField
    (t, objectClass(t, b), "effectiveDirectAddress", "J");

  return reinterpret_cast<void*>
    (fieldAtOffset<int64_t>(b, fieldOffset(t, field)));
}

void JNICALL
loadLibrary(Thread* t, object, uintptr_t* arguments)
{
  object name = reinterpret_cast<object>(arguments[1]);

  unsigned length = stringLength(t, name);
  THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
  stringChars(t, name, RUNTIME_ARRAY_BODY(n));

  loadLibrary(t, "", RUNTIME_ARRAY_BODY(n), true, true);
}

void JNICALL
finalizeAllEnqueued(Thread*, object, uintptr_t*)
{
  // ignore
}

int64_t JNICALL
appLoader(Thread* t, object, uintptr_t*)
{
  return reinterpret_cast<uintptr_t>(root(t, Machine::AppLoader));
}

int64_t JNICALL
defineClass(Thread* t, object method, uintptr_t* arguments)
{
  uintptr_t args[]
    = { arguments[0], arguments[2], arguments[3], arguments[4] };

  int64_t v = Avian_avian_Classes_defineVMClass(t, method, args);

  if (v) {<commit_msg>Ignoring requests to load native conscrypt_jni library - it's linked statically<commit_after>/* Copyright (c) 2008-2013, Avian Contributors

   Permission to use, copy, modify, and/or distribute this software
   for any purpose with or without fee is hereby granted, provided
   that the above copyright notice and this permission notice appear
   in all copies.

   There is NO WARRANTY for this software.  See license.txt for
   details. */

struct JavaVM;
struct _JNIEnv;

struct JniConstants {
  static void init(_JNIEnv* env);
};

extern "C" int JNI_OnLoad(JavaVM*, void*);

#define _POSIX_C_SOURCE 200112L
#undef _GNU_SOURCE
#include "avian/machine.h"
#include "avian/classpath-common.h"
#include "avian/process.h"
#include "avian/util.h"

#ifdef PLATFORM_WINDOWS
const char* getErrnoDescription(int err);		// This function is defined in mingw-extensions.cpp
#endif

using namespace vm;

extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_avian_Classes_defineVMClass
(Thread*, object, uintptr_t*);

namespace {

namespace local {

void*
getDirectBufferAddress(Thread* t, object b)
{
  PROTECT(t, b);

  object field = resolveField
    (t, objectClass(t, b), "effectiveDirectAddress", "J");

  return reinterpret_cast<void*>
    (fieldAtOffset<int64_t>(b, fieldOffset(t, field)));
}

void JNICALL
loadLibrary(Thread* t, object, uintptr_t* arguments)
{
  object name = reinterpret_cast<object>(arguments[1]);

  unsigned length = stringLength(t, name);
  THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
  stringChars(t, name, RUNTIME_ARRAY_BODY(n));

  /* org_conscrypt_NativeCrypto.o is linked statically, and in Avian build
  the package is named org.conscrypt.NativeCrypto. When Android code sees
  that name it thinks the library isn't linked as a part of Android, so it
  tries to load in dynamically, but there's actually no need to, so we
  just ignore this request. */
  if (strcmp(RUNTIME_ARRAY_BODY(n), "conscrypt_jni") != 0) {
    loadLibrary(t, "", RUNTIME_ARRAY_BODY(n), true, true);
}

void JNICALL
finalizeAllEnqueued(Thread*, object, uintptr_t*)
{
  // ignore
}

int64_t JNICALL
appLoader(Thread* t, object, uintptr_t*)
{
  return reinterpret_cast<uintptr_t>(root(t, Machine::AppLoader));
}

int64_t JNICALL
defineClass(Thread* t, object method, uintptr_t* arguments)
{
  uintptr_t args[]
    = { arguments[0], arguments[2], arguments[3], arguments[4] };

  int64_t v = Avian_avian_Classes_defineVMClass(t, method, args);

  if (v) {
{'fraction_non_alphanumeric': 0.10930809105251296, 'fraction_numerical': 0.013748027946810909, 'mean_word_length': 5.112947658402204, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6783119', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1484, 'n_words': 438}