示例
org.robolectric/robolectric 4.13: org.robolectric.junit.rules.BackgroundTestRule
已验证示例 — maven org.robolectric/robolectric 4.13: org.robolectric.junit.rules.BackgroundTestRule. contract 在 java 21 · linux 2023/x64 · docker 上运行并通过.
sha256:2f105e289aa0b12f19d289a6d8e67497ca494b0cd312eca193ce0829f7915021
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 5
- 构建过它的签名密钥
- 1
声明的环境
java 21 linux 24 · ubuntu · glibc 2.39 x64 java 21 java gradle 8
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| java 21 · linux 2023/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:PASS · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk21-corretto-al2023@sha256:05cb2f8b4a77… |
2026-09-09 |
| java 8 · linux 2023/x64 · docker ed25519:c1973797be207ac4 | FAIL | compile:PASS · contract:FAIL · load:SKIPPED · resolve:PASS CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk8-corretto-al2023@sha256:ec6379bf6453… |
2026-09-09 |
| java 11 · linux 2023/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk11-corretto-al2023@sha256:93d9f84a044f… |
2026-09-09 |
| java 17 · linux 2023/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:PASS · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk17-corretto-al2023@sha256:9a40f91169b9… |
2026-09-09 |
| java 25 · linux 2023/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:PASS · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gradle-java@1gradle:9.7.0-jdk25-corretto-al2023@sha256:bb35f0164972… |
2026-09-09 |
案例
HOW- 目标
- verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13
- 符号
-
- org.robolectric.junit.rules.BackgroundTestRule
- 环境
- java 21
- 创建时间
- 2026-09-09T05:57:00Z
契约
- org.robolectric.junit.rules.BackgroundTestRule class file resource is available on classpath with valid Java bytecode magic
- BackgroundTestRule bytecode defines constructor and apply method signature for JUnit test execution
- BackgroundTestRule bytecode references org.junit.rules.TestRule interface
- BackgroundTestRule inner annotation BackgroundTest class file resource is available on classpath with valid Java bytecode magic
文件
- PROMPT.md
- csx.json
- spec.json
- src/main/java/sample/Sample.java
- test/Contract.java
源代码
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:maven/org.robolectric/robolectric@4.13
Demonstrate these symbols/APIs:
- org.robolectric.junit.rules.BackgroundTestRule
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"buildCommand":["gradle","--offline","--no-daemon","--no-scan","--console=plain","--project-dir","/work/.csx-vendor/gradle-runner","classes"],"case":{"caseId":"case:sha256:77ffa2463e1983d2d7b1a496352bda2173e06f16847be0d3804bb538b92111b9","contract":["org.robolectric.junit.rules.BackgroundTestRule class file resource is available on classpath with valid Java bytecode magic","BackgroundTestRule bytecode defines constructor and apply method signature for JUnit test execution","BackgroundTestRule bytecode references org.junit.rules.TestRule interface","BackgroundTestRule inner annotation BackgroundTest class file resource is available on classpath with valid Java bytecode magic"],"goal":"verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13","kind":"HOW","packages":["pkg:maven/org.robolectric/robolectric@4.13"],"schemaVersion":1,"symbols":["org.robolectric.junit.rules.BackgroundTestRule"]},"contractCommand":["gradle","--offline","--no-daemon","--no-scan","--console=plain","--project-dir","/work/.csx-vendor/gradle-runner","contract"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"maven","language":"java","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"gradle","packageManagerVersion":"8.14.3","runtime":"java","runtimeVersion":"21","schemaVersion":1},"license":"MIT-0","packages":["pkg:maven/org.robolectric/robolectric@4.13"],"schemaVersion":1,"subject":"pkg:maven/org.robolectric/robolectric@4.13","symbols":["org.robolectric.junit.rules.BackgroundTestRule"],"verifierAdapter":"gradle-java@1"}
{
"schemaVersion": 1,
"goal": "verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13",
"kind": "HOW",
"packages": [
"pkg:maven/org.robolectric/robolectric@4.13"
],
"symbols": [
"org.robolectric.junit.rules.BackgroundTestRule"
]
}
package sample;
public class Sample {
public static String getSymbol() {
return "org.robolectric.junit.rules.BackgroundTestRule";
}
public static String getPackage() {
return "pkg:maven/org.robolectric/robolectric@4.13";
}
}
import sample.Sample;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class Contract {
private static byte[] readResource(ClassLoader loader, String path) throws Exception {
try (InputStream in = loader.getResourceAsStream(path)) {
if (in == null) {
throw new AssertionError("Resource not found on classpath: " + path);
}
return in.readAllBytes();
}
}
private static List<String> parseUtf8Constants(byte[] classBytes) throws Exception {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(classBytes));
int magic = dis.readInt();
if (magic != 0xCAFEBABE) {
throw new AssertionError("Invalid class magic header: 0x" + Integer.toHexString(magic));
}
int minor = dis.readUnsignedShort();
int major = dis.readUnsignedShort();
if (major < 49) {
throw new AssertionError("Unexpected JVM major version: " + major);
}
int cpCount = dis.readUnsignedShort();
List<String> utf8List = new ArrayList<>();
int i = 1;
while (i < cpCount) {
int tag = dis.readUnsignedByte();
switch (tag) {
case 1: // Utf8
String str = dis.readUTF();
utf8List.add(str);
break;
case 3: // Integer
case 4: // Float
dis.skipBytes(4);
break;
case 5: // Long
case 6: // Double
dis.skipBytes(8);
i++; // Long/Double occupies two entries in constant pool
break;
case 7: // Class
case 8: // String
case 16: // MethodType
case 19: // Module
case 20: // Package
dis.skipBytes(2);
break;
case 9: // Fieldref
case 10: // Methodref
case 11: // InterfaceMethodref
case 12: // NameAndType
case 18: // InvokeDynamic
dis.skipBytes(4);
break;
case 15: // MethodHandle
dis.skipBytes(3);
break;
default:
throw new AssertionError("Unknown constant pool tag: " + tag);
}
i++;
}
return utf8List;
}
public static void main(String[] args) {
try {
// 0. Verify sample helper
if (!"org.robolectric.junit.rules.BackgroundTestRule".equals(Sample.getSymbol())) {
throw new AssertionError("Sample symbol mismatch: " + Sample.getSymbol());
}
if (!"pkg:maven/org.robolectric/robolectric@4.13".equals(Sample.getPackage())) {
throw new AssertionError("Sample package mismatch: " + Sample.getPackage());
}
ClassLoader loader = Contract.class.getClassLoader();
// 1. Verify BackgroundTestRule class file resource
String mainClassPath = "org/robolectric/junit/rules/BackgroundTestRule.class";
byte[] mainBytes = readResource(loader, mainClassPath);
List<String> mainUtf8 = parseUtf8Constants(mainBytes);
// 2. Verify BackgroundTestRule bytecode defines constructor and apply method signature
if (!mainUtf8.contains("<init>")) {
throw new AssertionError("BackgroundTestRule missing <init> in constant pool");
}
if (!mainUtf8.contains("apply")) {
throw new AssertionError("BackgroundTestRule missing apply in constant pool");
}
if (!mainUtf8.contains("(Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement;")) {
throw new AssertionError("BackgroundTestRule missing apply descriptor in constant pool");
}
// 3. Verify BackgroundTestRule bytecode references org.junit.rules.TestRule interface
if (!mainUtf8.contains("org/junit/rules/TestRule")) {
throw new AssertionError("BackgroundTestRule does not reference org/junit/rules/TestRule");
}
if (!mainUtf8.contains("org/robolectric/junit/rules/BackgroundTestRule")) {
throw new AssertionError("BackgroundTestRule does not contain its own class name");
}
// 4. Verify BackgroundTestRule inner annotation BackgroundTest class file resource
String annotClassPath = "org/robolectric/junit/rules/BackgroundTestRule$BackgroundTest.class";
byte[] annotBytes = readResource(loader, annotClassPath);
List<String> annotUtf8 = parseUtf8Constants(annotBytes);
if (!annotUtf8.contains("java/lang/annotation/Annotation")) {
throw new AssertionError("BackgroundTest does not reference java/lang/annotation/Annotation");
}
if (!annotUtf8.contains("org/robolectric/junit/rules/BackgroundTestRule$BackgroundTest")) {
throw new AssertionError("BackgroundTest does not contain its own class name");
}
System.out.println("Contract PASS: org.robolectric.junit.rules.BackgroundTestRule contract verified successfully.");
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
}
原始种子者
匿名