Repository navigation
Commit 681a7dc
ADFA-6172: Keep Pebble whole through R8, so templated docs pages render (#2056)
Release builds minify the app module, and R8's shrinker removes members Pebble
only reaches by reflection. Two of its three reflective paths were broken:
- ExpressionParser instantiates unary operator nodes from a class literal
(CoreExtension registers `new UnaryOperatorImpl("not", 500,
UnaryNotExpression.class)`, the parser calls Class.newInstance() later). With no
traceable `new`, R8 strips the constructor and both evaluate() overrides and marks
the class abstract, so a template containing `{% if not x %}` fails to parse with
"java.lang.Class<...UnaryNotExpression> cannot be instantiated".
- MemberCacheUtils resolves template attributes with getField()/getMethods(), which
is how `loop.last` reaches ForNode$LoopVariables. Nothing calls its five getters
from bytecode, so R8 removes them and `loop.last` evaluates to null with no error
- wrong output rather than a crash.
layout.pebble hits both: 3,241 of the templated pages in documentation.db render
through it, and it uses `{%- if not loop.last %}`.
Keep the whole library rather than the two classes we caught. Attribute resolution
makes anything a layout can name reachable invisibly - both expression hierarchies,
LoopVariables and its lazy values, the `template` and `_context` globals, and every
filter, test and function a future template might use - and BinaryOperatorImpl still
exposes the same Class-based constructor to any Extension that ZipRecipeExecutor
loads through ServiceLoader. Enumerating that surface is how this recurs. Measured
against R8 8.8.34: ~31 KB more than keeping only the two known classes.
Verified with R8 8.8.34, the version AGP 8.8.2 uses, run against this rules file: an
80-check sweep of Pebble's operators, filters, tests, functions, tags and attribute
access produces output identical to an unshrunk run, where the previous rules gave
four parse crashes and silently empty loop variables. Debug builds do not minify, so
this only changes release output.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 12ce101 commit 681a7dc
1 file changed
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
191 | 226 | | |
192 | 227 | | |
193 | 228 | | |
| |||
0 commit comments