MyCATApache/Mycat-Server · critical · RuntimeException
RuntimeException(e)
Error message
RuntimeException(e)
What it means
The static initializer of io.mycat.memory.unsafe.ringbuffer.common.Sequence resolves the offset of the inner Value.value field via sun.misc.Unsafe.objectFieldOffset(Platform). If the reflection lookup fails for any reason, the catch block rethrows it as a RuntimeException, which surfaces as an ExceptionInInitializerError wrapping this RuntimeException on first use of the class.
Solutions
- Run on a JDK where sun.misc.Unsafe objectFieldOffset works (or add --add-opens for the relevant package on JDK 9+)
- Check the JVM security manager / policy isn't denying ReflectPermission
- Verify the mycat memory jar version is consistent — no mixed versions where Value was renamed
- Read the cause chain: ExceptionInInitializerError -> RuntimeException -> NoSuchFieldException tells exactly which lookup failed
Example fix
// before (JDK 16+ failure) java -jar app.jar // after java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -jar app.jar
Defensive patterns
Strategy: try-catch
Validate before calling
try {
Value.class.getDeclaredField("value"); // probe the reflective lookup before triggering class init
} catch (NoSuchFieldException e) {
throw new IllegalStateException("incompatible jar: Value.value missing", e);
} Try / catch
try {
Sequence seq = new Sequence();
} catch (Throwable t) {
Throwable cause = t.getCause(); // ExceptionInInitializerError -> RuntimeException -> reflection cause
throw new IllegalStateException("Sequence init failed on this JVM: " + cause, t);
} Prevention
- Test class init on the target JDK early; JDK 16+ may need --add-opens
- Pin consistent versions of the mycat memory jars
- Avoid security managers that deny ReflectPermission in this code path
- Read the full cause chain — the reflection exception names the missing member
When it happens
Trigger: Class initialization of Sequence on a JVM where Value.value cannot be reflectively accessed — e.g. a security manager denying reflection, a refactored/renamed Value class, or strict module access (JPMS) blocking sun.misc.Unsafe field access.
Common situations: Running on newer JDKs with strong encapsulation of internals; security policies in application servers; incompatible jar versions where the Value inner class changed.
Related errors
- rule function must implements
- No such field .
- Cannot construct as it does not have a no-args constructor
- Cannot construct
- Constructor for threw an exception
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/355764a0654e56ab.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/memory/unsafe/ringbuffer/common/sequence/Sequence.java:47
* of concurrent operations including CAS and order writes.
*
* <p>Also attempts to be more efficient with regards to false
* sharing by adding padding around the volatile field.
*/
public class Sequence extends RhsPadding
{
public static final long INITIAL_VALUE = -1L;
private static final long VALUE_OFFSET;
static
{
try
{
VALUE_OFFSET = Platform.objectFieldOffset(Value.class.getDeclaredField("value"));
}
catch (final Exception e)
{
throw new RuntimeException(e);
}
}
/**
* Create a sequence initialised to -1.
*/
public Sequence()
{
this(INITIAL_VALUE);
}
/**
* Create a sequence with a specified initial value.
*
* @param initialValue The initial value for this sequence.
*/
public Sequence(final long initialValue)
{View on GitHub (pinned to 65f8d8beb7)