Commit 3700cf4
authored
test(storage-nio): disable copying annotations for storage-nio (#13830)
In JSpecify 1.0.0, the `@NullMarked` annotation includes
`ElementType.MODULE` in its `@Target` metadata. Because
`ElementType.MODULE` was introduced in Java 9, reflecting on
`@NullMarked` classes under Java 8 (JDK 1.8) throws
`EnumConstantNotPresentExceptionProxy` wrapped in an
`ArrayStoreException`.
When unit tests run on Java 8, Mockito's default mock generation (via
ByteBuddy) attempts to copy all runtime class annotations from target
classes onto mock subclasses. This triggers the reflection crash when
mocking `Page` classes that are transitively annotated with
`@NullMarked`.
To bypass this Java 8 limitation:
* Replaced default Mockito mock instantiation of `Page` classes with
`Mockito.mock(Page.class, Mockito.withSettings().withoutAnnotations())`
in `CloudStorageIsDirectoryTest`.
* Disabling annotation copying prevents Mockito/ByteBuddy from invoking
`Class.getAnnotations()` on the target class during proxy creation,
allowing tests to run and mock stubs successfully on Java 8 pipelines.
Modified Mockito mock setups in:
* `CloudStorageIsDirectoryTest`1 parent 13964f2 commit 3700cf4
1 file changed
Lines changed: 3 additions & 2 deletions
File tree
- java-storage-nio/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
0 commit comments