Tabnine Logo
UnsafeTools
Code IndexAdd Tabnine to your IDE (free)

How to use
UnsafeTools
in
com.wizzardo.tools.reflection

Best Java code snippets using com.wizzardo.tools.reflection.UnsafeTools (Showing top 3 results out of 315)

origin: com.wizzardo/epoll

public static void arraycopy(ByteBuffer src, int srcPos, ByteBuffer dest, int destPos, int length) {
  if (length < 0)
    throw new IndexOutOfBoundsException("length must be >= 0. (length = " + length + ")");
  if (srcPos < 0)
    throw new IndexOutOfBoundsException("srcPos must be >= 0. (srcPos = " + srcPos + ")");
  if (destPos < 0)
    throw new IndexOutOfBoundsException("destPos must be >= 0. (destPos = " + destPos + ")");
  if (srcPos + length > src.capacity())
    throw new IndexOutOfBoundsException("srcPos + length must be <= src.capacity(). (srcPos = " + srcPos + ", length = " + length + ", capacity = " + src.capacity() + ")");
  if (destPos + length > dest.capacity())
    throw new IndexOutOfBoundsException("destPos + length must be <= dest.capacity(). (destPos = " + destPos + ", length = " + length + ", capacity = " + dest.capacity() + ")");
  if (SUPPORTED) {
    copy(src, srcPos, dest, destPos, length);
  } else {
    UnsafeTools.getUnsafe().copyMemory(address(src) + srcPos, address(dest) + destPos, length);
  }
}
origin: wizzardo/tools

  private void switchUnsafe(boolean enabled) throws NoSuchFieldException, IllegalAccessException {
    Field field = FieldReflectionFactory.class.getDeclaredField("unsafe");

    Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

    field.setAccessible(true);
    field.set(null, enabled ? UnsafeTools.getUnsafe() : null);
  }
}
origin: wizzardo/http

@Test
public void test_parameter_has_name() throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
  Constructor<java.lang.reflect.Parameter> parameterConstructor = (Constructor<java.lang.reflect.Parameter>) java.lang.reflect.Parameter.class.getDeclaredConstructors()[0];
  parameterConstructor.setAccessible(true);
  Method method = (Method) UnsafeTools.getUnsafe().allocateInstance(Method.class);
  java.lang.reflect.Parameter parameter = parameterConstructor.newInstance("fieldName", 0, method, 0);
  new FieldReflectionFactory().create(Executable.class, "hasRealParameterData", true).setBoolean(method, true);
  new FieldReflectionFactory().create(Executable.class, "parameters", true).setObject(method, Array.newInstance(java.lang.reflect.Parameter.class, 1));
  Assert.assertEquals("fieldName", ParametersHelper.getParameterName(parameter));
}
com.wizzardo.tools.reflectionUnsafeTools

Most used methods

  • getUnsafe

Popular in Java

  • Making http post requests using okhttp
  • startActivity (Activity)
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now