本文整理了Java中java.lang.Package.isSealed()
方法的一些代码示例,展示了Package.isSealed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.isSealed()
方法的具体详情如下:
包路径:java.lang.Package
类名称:Package
方法名:isSealed
[英]Indicates whether this package is sealed.
[中]指示此包是否已密封。
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
*/
public boolean isCompatibleTo(Package definedPackage) {
if (sealBase == null) {
return !definedPackage.isSealed();
} else {
return definedPackage.isSealed(sealBase);
}
}
代码示例来源:origin: spockframework/spock
private static boolean isComingFromSealedPackage(Class<?> type) {
return type.getPackage() != null && type.getPackage().isSealed();
}
代码示例来源:origin: robovm/robovm
Class<?> createClass(InputStream is, String packageName, String origName) {
if (is == null) {
return null;
}
byte[] clBuf;
try {
clBuf = Streams.readFully(is);
} catch (IOException e) {
return null;
}
if (packageName != null) {
String packageDotName = packageName.replace('/', '.');
Package packageObj = getPackage(packageDotName);
if (packageObj == null) {
definePackage(packageDotName, null, null,
null, null, null, null, null);
} else {
if (packageObj.isSealed()) {
throw new SecurityException("Package is sealed");
}
}
}
return defineClass(origName, clBuf, 0, clBuf.length, new CodeSource(codeSourceUrl, (Certificate[]) null));
}
代码示例来源:origin: robovm/robovm
boolean exception = packageObj.isSealed();
if (manifest != null) {
if (isSealed(manifest, packageName + "/")) {
exception = !packageObj
.isSealed(codeSourceUrl);
代码示例来源:origin: org.testifyproject.external/external-bytebuddy
@Override
public boolean isCompatibleTo(Package definedPackage) {
if (sealBase == null) {
return !definedPackage.isSealed();
} else {
return definedPackage.isSealed(sealBase);
}
}
代码示例来源:origin: com.fitbur.external/external-bytebuddy
@Override
public boolean isCompatibleTo(Package definedPackage) {
if (sealBase == null) {
return !definedPackage.isSealed();
} else {
return definedPackage.isSealed(sealBase);
}
}
代码示例来源:origin: ngs-doo/dsl-json
static String findConverterName(StructInfo structInfo) {
int dotIndex = structInfo.binaryName.lastIndexOf('.');
String className = structInfo.binaryName.substring(dotIndex + 1);
if (dotIndex == -1) return String.format("_%s_DslJsonConverter", className);
String packageName = structInfo.binaryName.substring(0, dotIndex);
Package packageClass = Package.getPackage(packageName);
boolean useDslPackage = packageClass != null && packageClass.isSealed() || structInfo.binaryName.startsWith("java.");
return String.format("%s%s._%s_DslJsonConverter", useDslPackage ? "dsl_json." : "", packageName, className);
}
代码示例来源:origin: ngs-doo/dsl-json
private boolean requiresPublic(Element element) {
if (onlyBasicFeatures) return true;
final String name = element.asType().toString();
if (name.startsWith("java.")) return true; //TODO: maybe some other namespaces !?
final PackageElement pkg = elements.getPackageOf(element);
if (pkg == null) return false;
final Package packageClass = Package.getPackage(pkg.getQualifiedName().toString());
return packageClass != null && packageClass.isSealed();
}
代码示例来源:origin: jmockit/jmockit1
@Nonnull
public static String getNameForGeneratedClass(@Nonnull Class<?> aClass, @Nullable String suffix) {
String prefix = aClass.isInterface() ? IMPLCLASS_PREFIX : SUBCLASS_PREFIX;
StringBuilder name = new StringBuilder(60).append(prefix).append(aClass.getSimpleName());
if (suffix != null) {
name.append('_').append(suffix);
}
if (aClass.getClassLoader() != null) {
Package targetPackage = aClass.getPackage();
if (targetPackage != null && !targetPackage.isSealed()) {
name.insert(0, '.').insert(0, targetPackage.getName());
}
}
return name.toString();
}
代码示例来源:origin: org.lastaflute/lasta-di
public String getEnhancedClassName() {
final StringBuffer buf = new StringBuffer(200);
final String targetClassName = targetClass.getName();
final Package pkg = targetClass.getPackage();
if (targetClassName.startsWith("java.") || (pkg != null && pkg.isSealed())) {
buf.append(PREFIX_ENHANCED_CLASS);
}
buf.append(targetClassName).append(SUFFIX_ENHANCED_CLASS).append(Integer.toHexString(hashCode()));
final int length = buf.length();
for (int i = 0; enhancedClassNames.contains(new String(buf)); ++i) {
buf.setLength(length);
buf.append("_").append(i);
}
String name = new String(buf);
enhancedClassNames.add(name);
return name;
}
代码示例来源:origin: org.lastaflute/lasta-di
public void setupConstructor() {
final Constructor<?>[] constructors = targetClass.getDeclaredConstructors();
if (constructors.length == 0) {
createDefaultConstructor(enhancedClass);
} else {
for (int i = 0; i < constructors.length; ++i) {
final int modifier = constructors[i].getModifiers();
final Package pkg = targetClass.getPackage();
if (Modifier.isPublic(modifier) || Modifier.isProtected(modifier) || (!Modifier.isPrivate(modifier)
&& !targetClass.getName().startsWith("java.") && (pkg == null || !pkg.isSealed()))) {
createConstructor(enhancedClass, constructors[i]);
}
}
}
}
代码示例来源:origin: org.seasar.container/s2-framework
/**
* {@link Constructor}のセットアップを行ないます。
*/
public void setupConstructor() {
final Constructor[] constructors = targetClass
.getDeclaredConstructors();
if (constructors.length == 0) {
createDefaultConstructor(enhancedClass);
} else {
for (int i = 0; i < constructors.length; ++i) {
final int modifier = constructors[i].getModifiers();
final Package pkg = targetClass.getPackage();
if (Modifier.isPublic(modifier)
|| Modifier.isProtected(modifier)
|| (!Modifier.isPrivate(modifier)
&& !targetClass.getName().startsWith("java.") && (pkg == null || !pkg
.isSealed()))) {
createConstructor(enhancedClass, constructors[i]);
}
}
}
}
代码示例来源:origin: org.netbeans.api/org-jruby
private static void validateArgs(Ruby runtime, String targetClassName, Class superClass) {
if (Modifier.isFinal(superClass.getModifiers())) {
throw runtime.newTypeError("cannot extend final class " + superClass.getName());
}
String targetPackage = packageName(targetClassName);
String pkg = targetPackage.replace('.', '/');
if (pkg.startsWith("java")) {
throw runtime.newTypeError("cannot add classes to package " + pkg);
}
Package p = Package.getPackage(pkg);
if (p != null) {
if (p.isSealed()) {
throw runtime.newTypeError("package " + p + " is sealed");
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "sealed?")
public IRubyObject sealed_p(ThreadContext context) {
final Package pkg = Package.getPackage(packageName);
if ( pkg == null ) return context.nil;
return context.runtime.newBoolean(pkg.isSealed());
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "sealed?")
public IRubyObject sealed_p(ThreadContext context) {
final Package pkg = Package.getPackage(packageName);
if ( pkg == null ) return context.nil;
return context.runtime.newBoolean(pkg.isSealed());
}
代码示例来源:origin: org.jruby/jruby-complete
private static void validateArgs(Ruby runtime, String targetClassName, Class superClass) {
if ( Modifier.isFinal(superClass.getModifiers()) ) {
throw runtime.newTypeError("cannot extend final class " + superClass.getName());
}
if ( ! hasPublicOrProtectedConstructor(superClass) ) {
throw runtime.newTypeError("class " + superClass.getName() + " doesn't have a public or protected constructor");
}
String targetPackage = packageName(targetClassName);
String packagePath = targetPackage.replace('.', '/');
if (packagePath.startsWith("java")) {
throw runtime.newTypeError("cannot add classes to package " + packagePath);
}
final Package pkg = Package.getPackage(packagePath);
if ( pkg != null && pkg.isSealed() ) {
throw runtime.newTypeError("package " + pkg + " is sealed");
}
}
代码示例来源:origin: org.jruby/jruby-core
private static void validateArgs(Ruby runtime, String targetClassName, Class superClass) {
if ( Modifier.isFinal(superClass.getModifiers()) ) {
throw runtime.newTypeError("cannot extend final class " + superClass.getName());
}
if ( ! hasPublicOrProtectedConstructor(superClass) ) {
throw runtime.newTypeError("class " + superClass.getName() + " doesn't have a public or protected constructor");
}
String targetPackage = packageName(targetClassName);
String packagePath = targetPackage.replace('.', '/');
if (packagePath.startsWith("java")) {
throw runtime.newTypeError("cannot add classes to package " + packagePath);
}
final Package pkg = Package.getPackage(packagePath);
if ( pkg != null && pkg.isSealed() ) {
throw runtime.newTypeError("package " + pkg + " is sealed");
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static void validateArgs(Ruby runtime, String targetClassName, Class superClass) {
if (Modifier.isFinal(superClass.getModifiers())) {
throw runtime.newTypeError("cannot extend final class " + superClass.getName());
}
if(!hasPublicOrProtectedConstructors(superClass)) {
throw runtime.newTypeError("class " + superClass.getName() + " doesn't have any public or private constructors");
}
String targetPackage = packageName(targetClassName);
String pkg = targetPackage.replace('.', '/');
if (pkg.startsWith("java")) {
throw runtime.newTypeError("cannot add classes to package " + pkg);
}
Package p = Package.getPackage(pkg);
if (p != null) {
if (p.isSealed()) {
throw runtime.newTypeError("package " + p + " is sealed");
}
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static void validateArgs(Ruby runtime, String targetClassName, Class superClass) {
if (Modifier.isFinal(superClass.getModifiers())) {
throw runtime.newTypeError("cannot extend final class " + superClass.getName());
}
if(!hasPublicOrProtectedConstructors(superClass)) {
throw runtime.newTypeError("class " + superClass.getName() + " doesn't have any public or private constructors");
}
String targetPackage = packageName(targetClassName);
String pkg = targetPackage.replace('.', '/');
if (pkg.startsWith("java")) {
throw runtime.newTypeError("cannot add classes to package " + pkg);
}
Package p = Package.getPackage(pkg);
if (p != null) {
if (p.isSealed()) {
throw runtime.newTypeError("package " + p + " is sealed");
}
}
}
代码示例来源:origin: org.apache.commons/commons-vfs2
/**
* Verify the package loaded with class loader.
*/
private void verifyPackage(final Package pack, final boolean sealed) {
if (getBaseFolder().getFileSystem().hasCapability(Capability.MANIFEST_ATTRIBUTES)) {
assertEquals("ImplTitle", pack.getImplementationTitle());
assertEquals("ImplVendor", pack.getImplementationVendor());
assertEquals("1.1", pack.getImplementationVersion());
assertEquals("SpecTitle", pack.getSpecificationTitle());
assertEquals("SpecVendor", pack.getSpecificationVendor());
assertEquals("1.0", pack.getSpecificationVersion());
assertEquals(sealed, pack.isSealed());
} else {
assertNull(pack.getImplementationTitle());
assertNull(pack.getImplementationVendor());
assertNull(pack.getImplementationVersion());
assertNull(pack.getSpecificationTitle());
assertNull(pack.getSpecificationVendor());
assertNull(pack.getSpecificationVersion());
assertFalse(pack.isSealed());
}
}
内容来源于网络,如有侵权,请联系作者删除!