net.openhft.chronicle.core.Jvm.getMethod()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中net.openhft.chronicle.core.Jvm.getMethod()方法的一些代码示例,展示了Jvm.getMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jvm.getMethod()方法的具体详情如下:
包路径:net.openhft.chronicle.core.Jvm
类名称:Jvm
方法名:getMethod

Jvm.getMethod介绍

暂无

代码示例

代码示例来源:origin: net.openhft/chronicle-values

public String inferModuleName(Location location) {
  try {
    Method inferModuleName = Jvm.getMethod(JavaFileManager.class, "inferModuleName", Location.class);
    return (String) inferModuleName.invoke(fileManager, location);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: net.openhft/chronicle-values

public Location getLocationForModule(Location location, JavaFileObject fo) {
  try {
    Method getLocationForModule = Jvm.getMethod(JavaFileManager.class, "getLocationForModule", Location.class, JavaFileObject.class);
    return (Location) getLocationForModule.invoke(fileManager, location, fo);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Values

public Location getLocationForModule(Location location, String moduleName) {
  try {
    Method getLocationForModule = Jvm.getMethod(JavaFileManager.class, "getLocationForModule", Location.class, String.class);
    return (Location) getLocationForModule.invoke(fileManager, location, moduleName);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Values

public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) {
  try {
    Method getServiceLoader = Jvm.getMethod(JavaFileManager.class, "getServiceLoader", Location.class, Class.class);
    return (ServiceLoader<S>) getServiceLoader.invoke(fileManager, location, service);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: net.openhft/chronicle-values

public Location getLocationForModule(Location location, String moduleName) {
  try {
    Method getLocationForModule = Jvm.getMethod(JavaFileManager.class, "getLocationForModule", Location.class, String.class);
    return (Location) getLocationForModule.invoke(fileManager, location, moduleName);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: net.openhft/chronicle-values

public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) {
  try {
    Method getServiceLoader = Jvm.getMethod(JavaFileManager.class, "getServiceLoader", Location.class, Class.class);
    return (ServiceLoader<S>) getServiceLoader.invoke(fileManager, location, service);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Values

public Iterable<Set<Location>> listLocationsForModules(Location location) {
  try {
    Method listLocationsForModules = Jvm.getMethod(JavaFileManager.class, "listLocationsForModules", Location.class);
    return (Iterable<Set<Location>>) listLocationsForModules.invoke(fileManager, location);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: net.openhft/chronicle-values

public Iterable<Set<Location>> listLocationsForModules(Location location) {
  try {
    Method listLocationsForModules = Jvm.getMethod(JavaFileManager.class, "listLocationsForModules", Location.class);
    return (Iterable<Set<Location>>) listLocationsForModules.invoke(fileManager, location);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: net.openhft/chronicle-values

public boolean contains(Location location, FileObject fo) {
    try {
      Method contains = Jvm.getMethod(JavaFileManager.class, "contains", Location.class, JavaFileObject.class);
      return (Boolean) contains.invoke(fileManager, location, fo);
    } catch (IllegalAccessException | InvocationTargetException e) {
      throw new AssertionError(e);
    }
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Values

public Location getLocationForModule(Location location, JavaFileObject fo) {
  try {
    Method getLocationForModule = Jvm.getMethod(JavaFileManager.class, "getLocationForModule", Location.class, JavaFileObject.class);
    return (Location) getLocationForModule.invoke(fileManager, location, fo);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Values

public String inferModuleName(Location location) {
  try {
    Method inferModuleName = Jvm.getMethod(JavaFileManager.class, "inferModuleName", Location.class);
    return (String) inferModuleName.invoke(fileManager, location);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Values

public boolean contains(Location location, FileObject fo) {
    try {
      Method contains = Jvm.getMethod(JavaFileManager.class, "contains", Location.class, JavaFileObject.class);
      return (Boolean) contains.invoke(fileManager, location, fo);
    } catch (IllegalAccessException | InvocationTargetException e) {
      throw new AssertionError(e);
    }
  }
}

代码示例来源:origin: net.openhft/chronicle-core

@Override
public void clean(final ByteBuffer buffer) {
  try {
    final Method cleanerMethod;
    cleanerMethod = DirectBuffer.class.
        getDeclaredMethod("cleaner");
    Jvm.setAccessible(cleanerMethod);
    final Object cleaner =
        cleanerMethod.invoke(buffer);
    final String cleanerClassname = Jvm.isJava9Plus() ?
        JDK9_CLEANER_CLASS_NAME : JDK8_CLEANER_CLASS_NAME;
    final Method cleanMethod = Jvm.getMethod(Class.forName(cleanerClassname), "clean");
    cleanMethod.invoke(cleaner);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
    LOGGER.warn("Failed to clean buffer", e);
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
public void clean(final ByteBuffer buffer) {
  try {
    final Method cleanerMethod;
    cleanerMethod = DirectBuffer.class.
        getDeclaredMethod("cleaner");
    Jvm.setAccessible(cleanerMethod);
    final Object cleaner =
        cleanerMethod.invoke(buffer);
    final String cleanerClassname = Jvm.isJava9Plus() ?
        JDK9_CLEANER_CLASS_NAME : JDK8_CLEANER_CLASS_NAME;
    final Method cleanMethod = Jvm.getMethod(Class.forName(cleanerClassname), "clean");
    cleanMethod.invoke(cleaner);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
    LOGGER.warn("Failed to clean buffer", e);
  }
}

相关文章