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

How to use
getProtectionDomain
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getProtectionDomain (Showing top 20 results out of 9,621)

origin: spring-projects/spring-framework

  public Object run() {
    return source.getProtectionDomain();
  }
});
origin: redisson/redisson

  public ProtectionDomain run() {
   return ClassDefinitionUtils.class.getProtectionDomain();
  }
});
origin: org.mockito/mockito-core

  @Override
  public ClassLoadingStrategy<ClassLoader> resolveStrategy(Class<?> mockedType, ClassLoader classLoader, boolean localMock) {
    return ClassLoadingStrategy.Default.INJECTION.with(localMock ? mockedType.getProtectionDomain() : InjectionBase.class.getProtectionDomain());
  }
}
origin: apache/incubator-dubbo

public static String getCodeBase(Class<?> cls) {
  if (cls == null) {
    return null;
  }
  ProtectionDomain domain = cls.getProtectionDomain();
  if (domain == null) {
    return null;
  }
  CodeSource source = domain.getCodeSource();
  if (source == null) {
    return null;
  }
  URL location = source.getLocation();
  if (location == null) {
    return null;
  }
  return location.getFile();
}
origin: apache/incubator-dubbo

public static String getCodeBase(Class<?> cls) {
  if (cls == null) {
    return null;
  }
  ProtectionDomain domain = cls.getProtectionDomain();
  if (domain == null) {
    return null;
  }
  CodeSource source = domain.getCodeSource();
  if (source == null) {
    return null;
  }
  URL location = source.getLocation();
  if (location == null) {
    return null;
  }
  return location.getFile();
}
origin: redisson/redisson

/**
 * Returns location of the class. If class is not in a jar, it's classpath
 * is returned; otherwise the jar location.
 */
public static String classLocation(Class clazz) {
  return clazz.getProtectionDomain().getCodeSource().getLocation().getPath();
}
origin: redisson/redisson

protected ProtectionDomain getDomain() {
  Class clazz;
  if (superClass != null && !superClass.getName().equals("java.lang.Object"))
    clazz = superClass;
  else if (interfaces != null && interfaces.length > 0)
    clazz = interfaces[0];
  else
    clazz = this.getClass();
  return clazz.getProtectionDomain();
}
origin: stackoverflow.com

return new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
origin: springside/springside4

  /**
   * 获得参数clazz所在的Jar文件的绝对路径
   */
  public static String getJarPath(Class<?> clazz) {
    return clazz.getProtectionDomain().getCodeSource().getLocation().getFile();
  }
}
origin: Tencent/tinker

private static void setRunningLocation(CliMain m) {
  mRunningLocation = m.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
  try {
    mRunningLocation = URLDecoder.decode(mRunningLocation, "utf-8");
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  if (mRunningLocation.endsWith(".jar")) {
    mRunningLocation = mRunningLocation.substring(0, mRunningLocation.lastIndexOf(File.separator) + 1);
  }
  File f = new File(mRunningLocation);
  mRunningLocation = f.getAbsolutePath();
}
origin: apache/incubator-dubbo

/**
 * Get the code source file or class path of the Class passed in.
 *
 * @param clazz
 * @return Jar file name or class path.
 */
public static String getCodeSource(Class<?> clazz) {
  ProtectionDomain protectionDomain = clazz.getProtectionDomain();
  if (protectionDomain == null || protectionDomain.getCodeSource() == null) {
    return null;
  }
  CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
  URL location = codeSource.getLocation();
  if (location == null) {
    return null;
  }
  String path = codeSource.getLocation().toExternalForm();
  if (path.endsWith(".jar") && path.contains("/")) {
    return path.substring(path.lastIndexOf('/') + 1);
  }
  return path;
}
origin: alibaba/Sentinel

static String getEagleEyeLocation() {
  try {
    URL resource = EagleEye.class.getProtectionDomain().getCodeSource().getLocation();
    if (resource != null) {
      return resource.toString();
    }
  } catch (Throwable t) {
    // ignore
  }
  return "unknown location";
}
origin: apache/incubator-dubbo

/**
 * Get the code source file or class path of the Class passed in.
 *
 * @param clazz
 * @return Jar file name or class path.
 */
public static String getCodeSource(Class<?> clazz) {
  ProtectionDomain protectionDomain = clazz.getProtectionDomain();
  if (protectionDomain == null || protectionDomain.getCodeSource() == null) {
    return null;
  }
  CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
  URL location = codeSource.getLocation();
  if (location == null) {
    return null;
  }
  String path = codeSource.getLocation().toExternalForm();
  if (path.endsWith(".jar") && path.contains("/")) {
    return path.substring(path.lastIndexOf('/') + 1);
  }
  return path;
}
origin: dropwizard/dropwizard

  @Override
  public String toString() {
    final URL location = klass.getProtectionDomain().getCodeSource().getLocation();
    try {
      final String jar = new File(location.toURI()).getName();
      if (jar.endsWith(".jar")) {
        return jar;
      }
      return "project.jar";
    } catch (Exception ignored) {
      return "project.jar";
    }
  }
}
origin: gocd/gocd

static File currentJarFile() {
  try {
    return new File(Boot.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
  } catch (URISyntaxException e) {
    throw new RuntimeException(e);
  }
}
origin: apache/incubator-druid

@SuppressWarnings("unchecked")
private Class<T> defineClass(String specializedClassName, byte[] specializedClassBytecode)
{
 return (Class<T>) UNSAFE.defineClass(
   specializedClassName,
   specializedClassBytecode,
   0,
   specializedClassBytecode.length,
   prototypeClass.getClassLoader(),
   prototypeClass.getProtectionDomain()
 );
}
origin: medcl/elasticsearch-analysis-ik

public Path getConfigInPluginDir() {
  return PathUtils
      .get(new File(AnalysisIkPlugin.class.getProtectionDomain().getCodeSource().getLocation().getPath())
          .getParent(), "config")
      .toAbsolutePath();
}
origin: apache/incubator-dubbo

public Class<?> toClass() {
  return toClass(ClassHelper.getClassLoader(ClassGenerator.class),
      getClass().getProtectionDomain());
}
origin: apache/incubator-dubbo

public Class<?> toClass() {
  return toClass(ClassHelper.getClassLoader(ClassGenerator.class),
      getClass().getProtectionDomain());
}
origin: apache/incubator-shardingsphere

@SneakyThrows
protected static Map<String, SQLCase> loadSQLCases(final String path) {
  File file = new File(SQLCasesLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath());
  return file.isFile() ? loadSQLCasesFromJar(path, file) : loadSQLCasesFromTargetDirectory(path);
}

java.langClassgetProtectionDomain

Javadoc

Returns null.

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
    Finds a resource with a given name. The rules for searching resources associated with a given class
  • 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

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Collectors (java.util.stream)
  • CodeWhisperer alternatives
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