nullaway
यह क्या करती है
यह स्किल आपके AI को NullAway की त्रुटियाँ ठीक करने में मार्गदर्शन देती है, जो Java कोड में संभावित null मान खोजने वाला टूल है। यह उन डेवलपर्स के लिए है जो null annotations जोड़ते या अपडेट करते हैं।
कब इस्तेमाल करें
- ✓जब NullAway किसी ऐसे मान के बारे में त्रुटि बताए जो null हो सकता है।
- ✓जब आप किसी Java फ़ाइल में @NullMarked जोड़ते हैं और नई चेतावनियाँ ठीक करनी हैं।
- ✓जब आपको nullable supplier या observable मान बिना कोड तोड़े पास करना है।
Skill का लिंक
https://github.com/chromium/chromium/blob/main/agents/skills/nullaway/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी Java फ़ाइल पर NullAway त्रुटि दिखा रहा है। क्या आप इसे बिना ऐप का व्यवहार बदले ठीक कर सकते हैं?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI देखता है कि हर संभावित-null मान कैसे इस्तेमाल होता है। फिर वह सुरक्षित जाँच या assertion जोड़ता है, और checker को संतुष्ट करने वाला सबसे हल्का विकल्प चुनता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Core Principles
1. Migration to @NullMarked vs New Code
The approach differs significantly depending on whether you are migrating
existing code to @NullMarked or writing new code in an already @NullMarked
context:
- Migration to
@NullMarked:- Goal: Satisfy the static analyzer while minimizing functional changes to avoid regressions.
- Practice: Use
NullUtil.assumeNonNull()when dereferencing immediately to satisfy the analyzer without runtime overhead. Useassertwhen storing or returning values. Useifguards occasionally if it helps avoid assertions, but avoid changing the logic.
- New Code (and modifying already
@NullMarkedcode):- Goal: Build robust, null-safe components from the ground up.
- Practice: Be more liberal with
asserts to enforce contracts. Rely on correct annotations (or their absence for implicit@NonNull) and only use null guards for@Nullablevalues.assumeNonNull()should generally not be used for new code.
2. No Functional Changes (For Migration)
- Rule: When migrating existing code, avoid adding new throwing runtime checks where they did not exist before, unless guided by the rules below.
3. assumeNonNull vs assert != null
The choice between assumeNonNull and Java assert depends on how the value is
used:
- Dereferencing
@Nullablevalues immediately: UseNullUtil.assumeNonNull(x).- Example:
var value = mSupplier.get(); assumeNonNull(value); value.doSomething(); - Why: If it is null, it will NPE on the dereference anyway.
assumeNonNullis a no-op that satisfies the analyzer without adding redundant runtime checks. - Style Rule:
assumeNonNull()should be on a separate line, almost always, rather than used inline. - Note: This rule is primarily for migrations to avoid functional
changes. For new code, rely on correct annotations and avoid
assumeNonNull().
- Example:
- Passing
@Nullablevalues to non-null parameters: First, look into the call tree of the receiver class and see if that parameter should be annotated as@Nullableor not. If it can natively handle null, update the method signature instead of adding an assertion. If it strictly requires a non-null value, THEN you MUST use a Javaassert x != null;on a preceding line before passing or storing it.[!CAUTION] NEVER use
assumeNonNull(x)to pass a@Nullablevalue to a non-null parameter or to return it from a non-nullable method. This is STRICTLY FORBIDDEN. You MUST use a Javaasserton a preceding line to add a runtime check.- Bad Example:
mReceiver.setSomething(assumeNonNull(nullableValue)); - Good Example:
assert nullableValue != null; mReceiver.setSomething(nullableValue);
- Bad Example:
- Returning
@Nullablevalues from non-nullable methods: First, consider if the method's return type can be safely updated to@Nullable. If it cannot (e.g., because it implements an interface or strictly enforces a non-null contract), you MUST use a Javaassert x != null;on a preceding line before returning the value. UsingassumeNonNull(x)inline within a return statement is strictly forbidden.- Bad Example:
return assumeNonNull(nullableValue); - Good Example:
assert nullableValue != null; return nullableValue;
- Bad Example:
- Why: Asserts add a runtime check (active in tests/debug) which is an
acceptable functional change. We rely on instrumentation tests to validate
these changes.
- Deep Investigation Rule: Before asserting or assuming non-null for a
passed value, investigate the call tree. If the method being called can be
updated to consider the parameter
@Nullable, prefer updating the method signature over adding an assertion. - Warning: Be careful with
assert value != nullonSupplier.get()during initialization. If the supplier value is set LATER (as is common with UI wiring), the assert might fail immediately during construction. In such cases, the getter should return@Nullableand callers should handle it, rather than asserting non-null immediately.
- Deep Investigation Rule: Before asserting or assuming non-null for a
passed value, investigate the call tree. If the method being called can be
updated to consider the parameter
4. Handling Suppliers and Generics
- Problem: Passing a
Supplier<@Nullable T>to a constructor that expectsSupplier<T>(non-nullable), or vice
अक्सर पूछे जाने वाले सवाल
NullAway क्या है?
NullAway एक checker है जो Java कोड में वे जगहें खोजता है जहाँ कोई मान खाली हो सकता है, और इससे क्रैश हो सकते हैं।
क्या इस सुधार से मेरे ऐप का व्यवहार बदलेगा?
पुराने कोड को माइग्रेट करते समय स्किल व्यवहार बदलने से बचने की कोशिश करती है। वह नए तर्क के बजाय छोटे assertions को प्राथमिकता देती है।
क्या यह केवल नए कोड के लिए है?
नहीं। यह पुराने कोड को null-marked कोड में ले जाने और पहले से इसका उपयोग करने वाली फ़ाइलों में नया कोड लिखने, दोनों को कवर करती है।
जानकारी
लेखक का मूल विवरण
Guide for resolving NullAway static analysis errors. Best practices for: - Passing ObservableSupplier/Supplier<@Nullable T> - Dereferencing potentially @Nullable values - Adding @NullMarked to Java code
repo: chromium/chromium
लोकप्रियता
- GitHub स्टार
- 25k
- रैंकिंग में स्थान
- #10062
- लाइसेंस
- BSD-3-Clause
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
fuzzing
25kयह आपके एजेंट को फ़ज़ टेस्ट लिखने में मदद करती है, जो कोड में बहुत से यादृच्छिक इनपुट डालकर C++ कोड में क्रैश और बग खोजते हैं।
gn-deps-debugging
25kयह आपके एजेंट को GN build फ़ाइलों में गायब या गलत निर्भरताओं से होने वाली build त्रुटियाँ ठीक करने में मदद करती है, बिना बड़ी और अनावश्यक निर्भरताएँ जोड़े।
java-memory-leaks
25kयह आपके एजेंट को LeakCanary की लीक रिपोर्ट पढ़कर Android ऐप्स में Java मेमोरी लीक खोजने और ठीक करने में मदद करती है।
jni-type-conversion
25kयह आपके एजेंट को Android कोड में हाथ से लिखे Java-से-C++ रूपांतरण कोड की जगह सरल @JniType annotations लगाने में मदद करती है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।