Courseiva
Java Platform Overview and PackaginghardMultiple ChoiceObjective-mapped

1Z0-829 Java Platform Overview and Packaging Practice Question

An application built with Java 17 uses a third-party library that internally uses `sun.misc.Unsafe`. The application runs without errors on Java 8 but throws an `IllegalAccessError` on Java 17. What is the most likely reason?

⚠ Common exam trap

Candidates often think the error is due to the library not being modular (Option D) or a missing module path (Option C), but the real cause is the default strong encapsulation of JDK internals in Java 17, which is a direct consequence of JEP 403.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Strong encapsulation of JDK internals is enforced by default.

In Java 17, strong encapsulation of JDK internals is enforced by default, meaning that code cannot access internal APIs like `sun.misc.Unsafe` via reflection or direct use unless explicitly opened. The `IllegalAccessError` occurs because the third-party library attempts to use `sun.misc.Unsafe`, which is a JDK internal API that is no longer accessible by default. This change was introduced as part of JEP 403 (Strongly Encapsulate JDK Internals) and finalized in Java 17, whereas Java 8 allowed such access.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The --illegal-access flag is set to permit.

    Why it's wrong here

    In Java 17, --illegal-access is removed; use --add-opens instead.

  • Strong encapsulation of JDK internals is enforced by default.

    Why this is correct

    Java 17 strongly encapsulates internal APIs by default, causing IllegalAccessError.

  • The module path does not include the library.

    Why it's wrong here

    The library is on classpath, which still works; access to sun.misc.Unsafe is restricted.

  • The library is not in a named module.

    Why it's wrong here

    The library may be unnamed, but that doesn't cause IllegalAccessError directly.

About these practice questions

One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.