Tabnine Logo
Class.getModule
Code IndexAdd Tabnine to your IDE (free)

How to use
getModule
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getModule (Showing top 18 results out of 315)

origin: scouter-project/scouter

/**
 * Loads a class file by {@code java.lang.invoke.MethodHandles.Lookup}.
 * It is obtained by using {@code neighbor}.
 *
 * @param neighbor  a class belonging to the same package that the loaded
 *                  class belogns to.
 * @param bcode     the bytecode.
 * @since 3.24
 */
public static Class<?> toClass(Class<?> neighbor, byte[] bcode)
  throws CannotCompileException
{
  try {
    DefineClassHelper.class.getModule().addReads(neighbor.getModule());
    Lookup lookup = MethodHandles.lookup();
    Lookup prvlookup = MethodHandles.privateLookupIn(neighbor, lookup);
    return prvlookup.defineClass(bcode);
  } catch (IllegalAccessException | IllegalArgumentException e) {
    throw new CannotCompileException(e.getMessage() + ": " + neighbor.getName()
                     + " has no permission to define the class");
  }
}
origin: org.javassist/javassist

/**
 * Loads a class file by {@code java.lang.invoke.MethodHandles.Lookup}.
 * It is obtained by using {@code neighbor}.
 *
 * @param neighbor  a class belonging to the same package that the loaded
 *                  class belogns to.
 * @param bcode     the bytecode.
 * @since 3.24
 */
public static Class<?> toClass(Class<?> neighbor, byte[] bcode)
  throws CannotCompileException
{
  try {
    DefineClassHelper.class.getModule().addReads(neighbor.getModule());
    Lookup lookup = MethodHandles.lookup();
    Lookup prvlookup = MethodHandles.privateLookupIn(neighbor, lookup);
    return prvlookup.defineClass(bcode);
  } catch (IllegalAccessException | IllegalArgumentException e) {
    throw new CannotCompileException(e.getMessage() + ": " + neighbor.getName()
                     + " has no permission to define the class");
  }
}
origin: org.eclipse.jetty/jetty-alpn-java-client

@Override
public boolean appliesTo(SSLEngine sslEngine)
{
  Module module = sslEngine.getClass().getModule();
  return module!=null && "java.base".equals(module.getName());
}
origin: org.eclipse.jetty/jetty-alpn-java-server

@Override
public boolean appliesTo(SSLEngine sslEngine)
{
  Module module = sslEngine.getClass().getModule();
  return module!=null && "java.base".equals(module.getName());
}
origin: hibernate/hibernate-demos

  @Override
  protected Lookup computeValue(Class<?> type) {
    if ( !getClass().getModule().canRead( type.getModule() ) ) {
      getClass().getModule().addReads( type.getModule() );
    }
    packageOpener.openPackageIfNeeded(
        type.getModule(), type.getPackageName(), FieldValueReaderImpl.class.getModule()
    );
    try {
      return MethodHandles.privateLookupIn( type, MethodHandles.lookup() );
    }
    catch (IllegalAccessException e) {
      throw new RuntimeException( e );
    }
  }
};
origin: io.github.tomdw.java.modules.spring/java-modules-context-boot

private static Module getCallerModule() {
  return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE)
      .walk(stackFrameStream -> stackFrameStream
          .map(StackWalker.StackFrame::getDeclaringClass)
          .map(Class::getModule)
          .filter(module -> module != ModuleContextRegistry.class.getModule())
          .findFirst()
          .orElseThrow(() -> new UnsupportedOperationException("Can only get an application context for a Module annotated with @ModuleContext")));
}
origin: io.github.tomdw.java.modules.spring/java-modules-context-boot

@Nullable
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
  Module usingModule = beanClass.getModule();
  for (Field field : beanClass.getDeclaredFields()) {
    if (field.isAnnotationPresent(ModuleServiceReference.class)) {
      Class<?> injectionType = field.getType();
      if(injectionType.isAssignableFrom(List.class)) {
        registerServiceListFactoryBean(usingModule, field);
      } else {
        registerServiceFactoryBean(usingModule, field);
      }
    }
  }
  return null;
}
origin: io.github.udaychandra/common

private void buildRef(MetadataItem.Reference reference, StringBuilder builder) {
  builder.append(reference.serviceClass().getModule().getName());
  builder.append(COLON);
  builder.append(reference.serviceClass().getName());
  builder.append(SEMI_COLON);
  builder.append(reference.setterMethodName());
  builder.append(SEMI_COLON);
  builder.append(reference.isList());
  builder.append(SEMI_COLON);
  builder.append(reference.isOptional());
}
origin: com.headius/modulator

public static Module getModule(Class cls) {
  if (JAVA_NINE) {
    return new Module9(cls.getModule());
  }
  return new ModuleDummy();
}
origin: net.colesico.framework/colesico-webstatic

public StaticContentBuilderImpl(
    @Message InjectionPoint injectionPoint,
    Provider<HttpContext> httpContextProv,
    ResourceKit resourceKit) {
  this.httpContextProv = httpContextProv;
  this.resourceKit = resourceKit;
  if (injectionPoint != null) {
    String moduleName = injectionPoint.getTargetClass().getModule().getName();
    if (moduleName!=null) {
      String contentRootPkg = moduleName.replace('.', '/') + "/" + DEFAULT_RESOURCES_DIR;
      this.resourcesRoot = contentRootPkg;
    } else {
      throw new RuntimeException("Unnamed module for injection point: "+injectionPoint);
    }
  }
  log.debug("Initial content root: " + resourcesRoot);
}
origin: org.tentackle/tentackle-common

/**
 * Creates a module info.
 *
 * @param hook the module hook
 */
public ModuleInfo(ModuleHook hook) {
 this.hook = hook;
 this.urlPath = hook.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
 this.module = hook.getClass().getModule();
 if (module == null || !module.isNamed()) {
  throw new TentackleRuntimeException(hook.getClass() + " does not belong to a named module");
 }
 requiredModuleNames = new HashSet<>();
 for (ModuleDescriptor.Requires req : module.getDescriptor().requires()) {
  requiredModuleNames.add(req.name());
 }
}
origin: io.github.udaychandra.susel/susel

  throws IOException, SuselMetadataNullException {
var module = serviceProvider.getModule();
var metadata = perModuleMetadataCache.get(module);
    var properties = new Properties();
    try (InputStream inStream = serviceProvider.getModule().getResourceAsStream(SUSEL_METADATA_RESOURCE_PATH)) {
      properties.load(inStream);
    } catch (NullPointerException ex) {
origin: io.github.scouter-project/scouter-agent-java

/**
 * Loads a class file by {@code java.lang.invoke.MethodHandles.Lookup}.
 * It is obtained by using {@code neighbor}.
 *
 * @param neighbor  a class belonging to the same package that the loaded
 *                  class belogns to.
 * @param bcode     the bytecode.
 * @since 3.24
 */
public static Class<?> toClass(Class<?> neighbor, byte[] bcode)
  throws CannotCompileException
{
  try {
    DefineClassHelper.class.getModule().addReads(neighbor.getModule());
    Lookup lookup = MethodHandles.lookup();
    Lookup prvlookup = MethodHandles.privateLookupIn(neighbor, lookup);
    return prvlookup.defineClass(bcode);
  } catch (IllegalAccessException | IllegalArgumentException e) {
    throw new CannotCompileException(e.getMessage() + ": " + neighbor.getName()
                     + " has no permission to define the class");
  }
}
origin: io.github.udaychandra/susel

  throws IOException, SuselMetadataNullException {
var module = serviceProvider.getModule();
var metadata = perModuleMetadataCache.get(module);
    var properties = new Properties();
    try (InputStream inStream = serviceProvider.getModule().getResourceAsStream(SUSEL_METADATA_RESOURCE_PATH)) {
      properties.load(inStream);
    } catch (NullPointerException ex) {
origin: net.colesico.framework/colesico-ioc

protected ServiceLocator(Class<?> caller, Class<S> service, ClassLoader classLoader, Predicate<Class<? extends S>> classFilter) {
  if (caller == null) {
    throw new ServiceConfigurationError("Caller class is null");
  }
  this.caller = caller;
  if (service == null) {
    throw new ServiceConfigurationError("Service class is null");
  }
  this.service = service;
  Module callerModule = caller.getModule();
  if (!callerModule.canUse(service)) {
    throw new ServiceConfigurationError("Module '" + callerModule + "' does not declare 'uses' for class " + service.getName());
  }
  if (classLoader != null) {
    this.classLoader = classLoader;
  } else {
    this.classLoader = ClassLoader.getSystemClassLoader();
  }
  this.classFilter = classFilter;
  this.acc = (System.getSecurityManager() != null)
      ? AccessController.getContext()
      : null;
}
origin: io.github.tomdw.java.modules.spring/java-modules-context-boot

public static <SERVICETYPE> SERVICETYPE retrieveInstanceFromContext(Class<SERVICETYPE> serviceClass) {
  LOGGER.log(INFO, "Providing instance of " + serviceClass.getSimpleName() + " from module " + serviceClass.getModule().getName());
  GenericApplicationContext context = get();
  if (!context.isActive()) {
    LOGGER.log(INFO, "Lazy starting ApplicationContext for module " + serviceClass.getModule().getName());
    context.refresh();
  }
  return context.getBean(serviceClass);
}
origin: bytemanproject/byteman

extraReads.add(AccessEnabler.class.getModule());
origin: bytemanproject/byteman

extraReads.add(AccessEnabler.class.getModule());
java.langClassgetModule

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • isAssignableFrom
    Determines if the class or interface represented by this Class object is either the same as, or is a
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • cast,
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for Android Studio
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