Java Guild course · Reference card

Reference · the starter code

Defect Inventory

Every flaw in the supplied code, with how it was reproduced. Verified against the real starter on 2026-08-30.

How to use this card

This is the master list. Print it, and tick items off as you fix them. Before the interview, read the Severity column and be able to justify the ordering — ranking defects is a more senior skill than finding them.

Tier 1 — must fix (they are the stated requirements)

#DefectEvidenceSeverity
D1 No tests at all. src/test/ does not exist. mvn test →
No tests to run.
Graduate requirement unmet
D2 The three exception classes are never used. Nothing imports, throws or catches them. grep -rn "AlreadyBorrowed
Exception" src/main → only its own file
Intermediate requirement unmet
D3 IOException signals domain failure. Neither borrowBook nor returnBook performs I/O. Signature: throws IOException Wrong abstraction
D4 The library lies. Borrowing an already-borrowed book reports that the book was not found. IOException: Book not found: Dune
(after Dune was added and borrowed)
High — misleads debugging
D5 Same conflation on return. The "or" in the message is the smell. Book not found or not borrowed: Dune Medium

Tier 2 — data loss and crashes

#DefectEvidenceSeverity
D6 Unescaped separator destroys data. A ; in a title silently shifts every field. Saved: Coming Home; A Novel by Rosamunde Pilcher
Reloaded: Coming Home by  A Novel
Critical — silent corruption
D7 Failed load destroys the library. books.clear() runs before the file is opened. 1 book in memory, load a missing file → throws, and 0 books remain Critical — data loss
D8 Parser trusts its input. parts[2] with no length check. ArrayIndexOutOfBoundsException:
Index 2 out of bounds for length 2
High
D9 Any non-digit at the menu kills the app — and the session’s work with it, since state is only saved on option 6. InputMismatchException
at Main.main(Main.java:72)
High
D10 A typo kills the app. Main catches IOException and rethrows as RuntimeException. RuntimeException: java.io.IOException:
Book not found: Gone With The Wind
High

Tier 3 — design and API

#DefectNote
D11searchBook returns null.Return Optional<Book>. Verified: returns literal null for an absent title.
D12Dead boolean returns.borrowBook can only return true — every other path throws.
D13Library is also a file format.Two reasons to change. Extract LibraryRepository; makes the Advanced SQLite tier additive.
D14Main is untestable.90-line static method, hardwired System.in/System.out, giant switch.
D15Menu text duplicates the option constants.A MENU string plus six int constants, kept in step by hand. Replace with an enum that renders the menu.
D16No equals/hashCode on Book.Verified: two books with identical title and author are not equal. Breaks contains, remove, and assertions on books.
D17Menu constants are public.On a final class with a private constructor. Nothing outside needs them.
D18Title is the de facto identity.So a library cannot hold two copies of one title. A genuine domain gap — name it in the README, do not build it.
D19Prompt then newline.println(MENU) where MENU ends "Enter your choice: ", so the cursor drops a line below the prompt.
D20scanner.close() closes System.in.Harmless at exit here, but a habit that breaks anything reading stdin later.

Tier 4 — build

#DefectEvidence
D21 source/target instead of release. [WARNING] location of system modules is not set in
conjunction with -source 11
--release 11 is recommended instead
D22<groupId>groupId</groupId> — an unedited placeholder.
D23libraryState.txt is not git-ignored and is written into the working directory.
D24Checkstyle is declared under <reporting> only, with no configLocation — so it uses sun_checks.xml and runs only under mvn site.Explains the final parameters and javadoc-on-everything style. Match it.
Not a defect — a constraint

The pom pins Java 11. That is not a bug to fix; it is a boundary to work inside. No records, no sealed types, no switch expressions, no text blocks, no Stream.toList(). Verified: javac --release 11 gives “records are not supported in -source 11”. JDK 25 still accepts --release 8, 11, 17, 21 and 25, so staying on 11 is safe on any assessor’s machine.

Reproduce them yourself

cd ~/Desktop/java-guild-candidate-test-intermediate-main
export JAVA_HOME=$(/usr/libexec/java_home -v 25)
~/.local/maven/bin/mvn clean compile

# D9 - a letter at the menu
printf 'x\n' | "$JAVA_HOME/bin/java" -cp target/classes \
    com.solirius.intermediate.library.Main

# D10 - borrowing something absent
printf '4\nGone With The Wind\n' | "$JAVA_HOME/bin/java" -cp target/classes \
    com.solirius.intermediate.library.Main

# D6 - the semicolon. Add the book, exit, restart, list.
printf '1\nComing Home; A Novel\nRosamunde Pilcher\n6\n' | \
    "$JAVA_HOME/bin/java" -cp target/classes com.solirius.intermediate.library.Main
printf '2\n6\n' | "$JAVA_HOME/bin/java" -cp target/classes \
    com.solirius.intermediate.library.Main
rm -f libraryState.txt