本文整理了Java中java.lang.LinkageError.<init>()
方法的一些代码示例,展示了LinkageError.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkageError.<init>()
方法的具体详情如下:
包路径:java.lang.LinkageError
类名称:LinkageError
方法名:<init>
[英]Constructs a new LinkageError that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新LinkageError。
代码示例来源:origin: neo4j/neo4j
/**
* @throws java.lang.LinkageError if the Unsafe tools are not available on in this JVM.
*/
public static void assertHasUnsafe()
{
if ( unsafe == null )
{
throw new LinkageError( "Unsafe not available" );
}
}
代码示例来源:origin: neo4j/neo4j
public T create( InvocationHandler handler )
{
try
{
return constructor.newInstance( handler );
}
catch ( Exception e )
{
throw new LinkageError( "Failed to create proxy instance", e );
}
}
代码示例来源:origin: neo4j/neo4j
/**
* Get the object-relative field offset.
*/
public static long getFieldOffset( Class<?> type, String field )
{
try
{
return unsafe.objectFieldOffset( type.getDeclaredField( field ) );
}
catch ( NoSuchFieldException e )
{
String message = "Could not get offset of '" + field + "' field on type " + type;
throw new LinkageError( message, e );
}
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
ProxyFactory( Class<T> type ) throws LinkageError
{
this.type = type;
try
{
this.constructor = (Constructor<? extends T>) Proxy
.getProxyClass( ConsistencyReporter.class.getClassLoader(), type )
.getConstructor( InvocationHandler.class );
instances.put( type, this );
}
catch ( NoSuchMethodException e )
{
throw new LinkageError( "Cannot access Proxy constructor for " + type.getName(), e );
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void close()
{
try
{
cleanHandle.invoke( cleaner );
}
catch ( Throwable throwable )
{
throw new LinkageError( "Unable to clean cleaner.", throwable );
}
}
代码示例来源:origin: neo4j/neo4j
private Object positionLock( FileChannel channel )
{
sun.nio.ch.FileChannelImpl impl = (FileChannelImpl) channel;
try
{
return (Object) positionLockGetter.invokeExact( impl );
}
catch ( Throwable th )
{
throw new LinkageError( "No getter for FileChannel.positionLock", th );
}
}
代码示例来源:origin: neo4j/neo4j
/**
* Create a string with a char[] that you know is not going to be modified, so avoid the copy constructor.
*
* @param chars array that will back the new string
* @return the created string
*/
public static String newSharedArrayString( char[] chars )
{
if ( sharedStringConstructor != null )
{
try
{
return (String) sharedStringConstructor.invokeExact( chars, true );
}
catch ( Throwable throwable )
{
throw new LinkageError( "Unexpected 'String constructor' intrinsic failure", throwable );
}
}
else
{
return new String( chars );
}
}
代码示例来源:origin: neo4j/neo4j
throw new LinkageError( "Bad code loading order.", e );
代码示例来源:origin: jenkinsci/jenkins
throw (LinkageError)new LinkageError("Failed to resolve "+c).initCause(x);
代码示例来源:origin: neo4j/neo4j
LinkageError error = new LinkageError( "No static field of type sun.misc.Unsafe" );
error.addSuppressed( e );
throw error;
throw new LinkageError( "Cannot access sun.misc.Unsafe", e );
代码示例来源:origin: google/error-prone
private BugChecker instantiateChecker(BugCheckerInfo checker) {
// Invoke BugChecker(ErrorProneFlags) constructor, if it exists.
@SuppressWarnings("unchecked")
/* getConstructors() actually returns Constructor<BugChecker>[], though the return type is
* Constructor<?>[]. See getConstructors() javadoc for more info. */
Optional<Constructor<BugChecker>> flagsConstructor =
Arrays.stream((Constructor<BugChecker>[]) checker.checkerClass().getConstructors())
.filter(
c -> Arrays.equals(c.getParameterTypes(), new Class<?>[] {ErrorProneFlags.class}))
.findFirst();
if (flagsConstructor.isPresent()) {
try {
return flagsConstructor.get().newInstance(getFlags());
} catch (ReflectiveOperationException e) {
throw new LinkageError("Could not instantiate BugChecker.", e);
}
}
// If no flags constructor, invoke default constructor.
try {
return checker.checkerClass().getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new LinkageError("Could not instantiate BugChecker.", e);
}
}
代码示例来源:origin: neo4j/neo4j
private static CleanerHandles findHandlesForOldCleaner( MethodHandles.Lookup lookup )
{
try
{
Class<?> oldCleaner = Class.forName( "sun.misc.Cleaner" );
return CleanerHandles.of( findCreationMethod( "create", lookup, oldCleaner ), findCleanMethod( lookup, oldCleaner ) );
}
catch ( ClassNotFoundException | NoSuchMethodException | IllegalAccessException oldCleanerException )
{
throw new LinkageError( "Unable to find cleaner methods.", oldCleanerException );
}
}
代码示例来源:origin: neo4j/neo4j
private static CleanerHandles findHandlesForNewCleaner( MethodHandles.Lookup lookup )
{
try
{
Objects.requireNonNull( globalCleanerInstance );
Class<?> newCleaner = globalCleanerInstance.getClass();
Class<?> newCleanable = Class.forName( "java.lang.ref.Cleaner$Cleanable" );
MethodHandle registerHandle = findCreationMethod( "register", lookup, newCleaner );
registerHandle = registerHandle.bindTo( globalCleanerInstance );
return CleanerHandles.of( registerHandle, findCleanMethod( lookup, newCleanable ) );
}
catch ( ClassNotFoundException | NoSuchMethodException | IllegalAccessException newCleanerException )
{
throw new LinkageError( "Unable to find cleaner methods.", newCleanerException );
}
}
代码示例来源:origin: google/error-prone
/** @deprecated prefer {@link #logFatalError(Log, Context)} */
@Deprecated
public void logFatalError(Log log) {
String version = ErrorProneVersion.loadVersionFromPom().or("unknown version");
JavaFileObject prev = log.currentSourceFile();
try {
log.useSource(source);
// use reflection since this overload of error doesn't exist in JDK >= 11
Method m =
Log.class.getMethod("error", DiagnosticPosition.class, String.class, Object[].class);
m.invoke(
log,
pos,
"error.prone.crash",
Throwables.getStackTraceAsString(cause),
version,
checkName);
} catch (ReflectiveOperationException e) {
throw new LinkageError(e.getMessage(), e);
} finally {
log.useSource(prev);
}
}
代码示例来源:origin: google/error-prone
((Resolve.InapplicableMethodException) e.getTargetException()).getDiagnostic()));
throw new LinkageError(e.getMessage(), e.getCause());
} catch (ReflectiveOperationException e) {
throw new LinkageError(e.getMessage(), e);
代码示例来源:origin: neo4j/neo4j
/**
* Create a new GrabAllocator that will allocate the given amount of memory, to pointers that are aligned to the
* given alignment size.
* @param expectedMaxMemory The maximum amount of memory that this memory manager is expected to allocate. The
* actual amount of memory used can end up greater than this value, if some of it gets wasted on alignment padding.
* @param memoryTracker memory usage tracker
*/
GrabAllocator( long expectedMaxMemory, MemoryAllocationTracker memoryTracker )
{
this.grabs = new Grabs( expectedMaxMemory, memoryTracker );
try
{
CleanerHandles handles = findCleanerHandles();
this.cleaner = handles.creator.invoke( this, new GrabsDeallocator( grabs ) );
this.cleanHandle = handles.cleaner;
}
catch ( Throwable throwable )
{
throw new LinkageError( "Unable to instantiate cleaner", throwable );
}
}
代码示例来源:origin: google/error-prone
/** Finds a declaration with the given name and type that is in scope at the current location. */
@Nullable
public static Symbol findIdent(String name, VisitorState state, KindSelector kind) {
ClassType enclosingClass = ASTHelpers.getType(state.findEnclosing(ClassTree.class));
if (enclosingClass == null || enclosingClass.tsym == null) {
return null;
}
Env<AttrContext> env = Enter.instance(state.context).getClassEnv(enclosingClass.tsym);
MethodTree enclosingMethod = state.findEnclosing(MethodTree.class);
if (enclosingMethod != null) {
env = MemberEnter.instance(state.context).getMethodEnv((JCMethodDecl) enclosingMethod, env);
}
try {
Method method =
Resolve.class.getDeclaredMethod("findIdent", Env.class, Name.class, KindSelector.class);
method.setAccessible(true);
Symbol result =
(Symbol) method.invoke(Resolve.instance(state.context), env, state.getName(name), kind);
return result.exists() ? result : null;
} catch (ReflectiveOperationException e) {
throw new LinkageError(e.getMessage(), e);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void manualThrowIfFatal() {
try {
Exceptions.throwIfFatal(new ThreadDeath());
fail("Didn't throw fatal exception");
} catch (ThreadDeath ex) {
// expected
}
try {
Exceptions.throwIfFatal(new LinkageError());
fail("Didn't throw fatal error");
} catch (LinkageError ex) {
// expected
}
try {
ExceptionHelper.wrapOrThrow(new LinkageError());
fail("Didn't propagate Error");
} catch (LinkageError ex) {
// expected
}
}
代码示例来源:origin: springside/springside4
@Test
public void unchecked() {
// convert Exception to RuntimeException with cause
Exception exception = new Exception("my exception");
try {
ExceptionUtil.unchecked(exception);
fail("should fail before");
} catch (Throwable t) {
assertThat(t.getCause()).isSameAs(exception);
}
// do nothing of Error
Error error = new LinkageError();
try {
ExceptionUtil.unchecked(error);
fail("should fail before");
} catch (Throwable t) {
assertThat(t).isSameAs(error);
}
// do nothing of RuntimeException
RuntimeException runtimeException = new RuntimeException("haha");
try {
ExceptionUtil.unchecked(runtimeException);
fail("should fail before");
} catch (Throwable t) {
assertThat(t).isSameAs(runtimeException);
}
}
代码示例来源:origin: apache/flink
@Test
public void testJvmFatalError() {
// not all errors are fatal
assertFalse(ExceptionUtils.isJvmFatalError(new Error()));
// linkage errors are not fatal
assertFalse(ExceptionUtils.isJvmFatalError(new LinkageError()));
// some errors are fatal
assertTrue(ExceptionUtils.isJvmFatalError(new InternalError()));
assertTrue(ExceptionUtils.isJvmFatalError(new UnknownError()));
}
内容来源于网络,如有侵权,请联系作者删除!