Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>GlassBox for JavaNew to Visual Studio Code? Get it now.
GlassBox for Java

GlassBox for Java

macstab

|
1 install
| (0) | Free
Test private code directly with GlassBox: no false access errors in tests, quick fixes that open a member, completion, and reflection rewritten into plain Java.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

GlassBox: test private code directly

GitHub · Getting started · IDE support · Changelog

GlassBox opens private members and types for tests only: the Gradle or Maven plugin opens elements marked @GlassBox in a copy of the compiled classes that only the tests see; the published jars stay unchanged. This extension makes the Java language server of Language Support for Java by Red Hat accept those accesses in tests; main code keeps every access check.

Features

  • No access errors in tests where the build allows the access (agent limits).
  • Quick fixes (Ctrl+.) on "is not visible": Open 'Calc.state' for tests with @GlassBox, ... only for CalcTest with @GlassBox, and Open 'Client.reset()' for this test class with @GlassBoxFor for libraries.
  • Completion of members not opened yet, marked (not opened: choosing it opens it with @GlassBox).
  • Refactor... > Replace reflection with direct access: ReflectionTestUtils, commons-lang3, Whitebox and getDeclared* / setAccessible become plain Java, and the targets are opened.
  • CodeLens Opened for tests by @GlassBox · N uses in tests over every opened member.
  • Declaration diagnostics with the build's rule ids (GB0101 to GB0212).

Setup

Add GlassBox to the build (Gradle or Maven) and install this extension. On first start it asks to add its agent to java.jdt.ls.vmargs, for all projects or this workspace, and to reload the window. GlassBox: Remove the agent from the Java language server undoes it.

@GlassBox("discount rules are tested in isolation")
private BigDecimal applyDiscount(BigDecimal price) { ... }

assertEquals(new BigDecimal("9.00"), calculator.applyDiscount(BigDecimal.TEN));   // in a test

Run tests with Gradle or Maven: only the build plugins produce the opened classes.

Requires VS Code 1.90+, Language Support for Java by Red Hat, and projects on Java 17+ built with Gradle 8.13+ or Maven 3.9+.


Created by Christian Schnapka (GitHub) · Macstab GmbH · Apache License 2.0

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft