Skip to content

Fix Java 21 compatibility issues by replacing getFirst() with get(0)#348

Closed
Copilot wants to merge 3 commits intocodex/create-expiration-event-class-and-methodsfrom
copilot/fix-fd0f53e6-4cc6-43c7-980b-8ce0771805ef
Closed

Fix Java 21 compatibility issues by replacing getFirst() with get(0)#348
Copilot wants to merge 3 commits intocodex/create-expiration-event-class-and-methodsfrom
copilot/fix-fd0f53e6-4cc6-43c7-980b-8ce0771805ef

Conversation

Copy link

Copilot AI commented Aug 12, 2025

Problem

The codebase was using Java 21's List.getFirst() method in multiple locations, causing compilation failures when building with Java 17. This created a barrier for developers and CI systems that haven't upgraded to Java 21 yet.

Changes

Replaced all instances of List.getFirst() with the Java 17 compatible List.get(0) method across 8 files:

Main Source Files

  • nostr-java-event/src/main/java/nostr/event/filter/Filters.java - Filter validation logic
  • nostr-java-event/src/main/java/nostr/event/impl/MerchantEvent.java - Merchant event attribute access
  • nostr-java-event/src/main/java/nostr/event/json/codec/FiltersEncoder.java - JSON encoding logic

Test Files

  • nostr-java-event/src/test/java/nostr/event/unit/PriceTagTest.java - Price tag comparison tests
  • nostr-java-event/src/test/java/nostr/event/unit/RelaysTagTest.java - Relay tag deserialization tests
  • nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java - JSON parsing unit tests
  • nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99RequestIT.java - Integration tests
  • nostr-java-id/src/test/java/nostr/id/EventTest.java - Event ID tests

Testing

  • ✅ Compilation successful with Java 17
  • ✅ All existing tests pass
  • mvn verify completes successfully
  • ✅ No functional changes - purely compatibility fix

Impact

This change maintains backward compatibility while ensuring the project can be built and tested with Java 17, removing the hard dependency on Java 21 for basic compilation.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

erict875 and others added 3 commits August 1, 2025 07:29
# Conflicts:
#	buildSrc/build.gradle
#	gradle.properties
#	nostr-java-api/pom.xml
#	nostr-java-base/pom.xml
#	nostr-java-client/pom.xml
#	nostr-java-crypto/pom.xml
#	nostr-java-encryption/pom.xml
#	nostr-java-event/pom.xml
#	nostr-java-examples/pom.xml
#	nostr-java-id/pom.xml
#	nostr-java-util/pom.xml
#	pom.xml
@tcheeric tcheeric changed the base branch from main to codex/create-expiration-event-class-and-methods August 12, 2025 02:12
@tcheeric tcheeric closed this Aug 12, 2025
Copilot AI changed the title [WIP] Revert commit e835e3700e7772eeec83d1db9d4ffe1ec52745cf due to compilation error Fix Java 21 compatibility issues by replacing getFirst() with get(0) Aug 12, 2025
Copilot AI requested a review from tcheeric August 12, 2025 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments