• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Change Log
2==========
3
4JavaPoet 1.13.0 *(2020-06-18)*
5-----------------------------
6
7 * New: Add support for explicit receiver parameters.
8 * Fix: Don't copy parameter annotations when creating a `ParameterSpec`.
9
10
11JavaPoet 1.12.1 *(2020-01-20)*
12-----------------------------
13
14 * Fix: Ignore parameter annotations in `MethodSpec.overriding()`.
15
16
17JavaPoet 1.12.0 *(2020-01-09)*
18-----------------------------
19
20 * New: Add `JavaFile.writeToPath()` and `JavaFile.writeToFile()` methods that return paths to the
21   generated file as `Path` and `File` respectively.
22 * New: Add `TypeSpec.alwaysQualify()` API to avoid clashes involving nested type names.
23 * New: Add overloads accepting `CodeBlock`s to `MethodSpec`'s control flow methods.
24 * New: Make list fields of all `Builder` types mutable.
25 * New: Add `CodeBlock.clear()`.
26 * New: Allow passing a custom `Charset` to `JavaFile.writeTo()`.
27 * New: Improved performance of `ClassName.simpleNames()` by memoizing results.
28 * New: Significant performance improvements for `CodeWriter.resolve()` as all nested simple names
29   of a `TypeSpec` get pre-computed.
30 * New: Add `TypeName.Builder.setName()` to allow overriding names passed in the constructor.
31 * New: Add `TypeName.canonicalName()`.
32 * Fix: Use `\\R` instead of `\n` as line separator in `CodeWriter.emitAndIndent()`.
33 * Fix: Copy originating elements in `TypeSpec.toBuilder()`.
34 * Fix: Ensure trailing newlines in Javadocs and method bodies.
35 * Fix: Copy annotations when creating a `ParameterSpec` from a `VariableElement`.
36 * Fix: Properly handle classes located in empty packages in `ClassName`.
37 * Fix: Only allow `final` modifier on a `ParameterSpec`.
38 * Fix: Use fully-qualified names for type names that are masked by type variable names.
39
40
41JavaPoet 1.11.1 *(2018-05-16)*
42-----------------------------
43
44 * Fix: JavaPoet 1.11 had a regression where `TypeName.get()` would throw on error types, masking
45   other errors in an annotation processing round. This is fixed with a test to prevent future
46   regressions!
47
48
49JavaPoet 1.11.0 *(2018-04-29)*
50-----------------------------
51
52 * New: Support `TYPE_USE` annotations on each enclosing `ClassName`.
53 * New: Work around a compiler bug in `TypeName.get(TypeElement)`. There was a problem getting an
54   element's kind when building from source ABIs.
55
56
57JavaPoet 1.10.0 *(2018-01-27)*
58-----------------------------
59
60 * **JavaPoet now requires Java 8 or newer.**
61 * New: `$Z` as an optional newline (zero-width space) if a line may exceed 100 chars.
62 * New: `CodeBlock.join()` and `CodeBlock.joining()` let you join codeblocks by delimiters.
63 * New: Add `CodeBlock.Builder.isEmpty()`.
64 * New: `addStatement(CodeBlock)` overloads for `CodeBlock` and `MethodSpec`.
65 * Fix: Include annotations when emitting type variables.
66 * Fix: Use the right imports for annotated type parameters.
67 * Fix: Don't incorrectly escape classnames that start with `$`.
68
69
70JavaPoet 1.9.0 *(2017-05-13)*
71-----------------------------
72
73 * Fix: Don't emit incorrect code when the declared type's signature references another type with
74   the same simple name.
75 * Fix: Support anonymous inner classes in `ClassName.get()`.
76 * New: `MethodSpec.Builder.addNamedCode()` and `TypeSpec.anonymousClassBuilder(CodeBlock)`.
77
78
79JavaPoet 1.8.0 *(2016-11-09)*
80-----------------------------
81
82 * New: Basic support for line wrapping. Use `$W` to insert a Wrappable Whitespace character. It'll
83   emit either a single space or a newline with appropriate indentation.
84 * New: Named arguments in `CodeBlock`. These are intended to make larger code snippets easier to
85   read:
86
87   ```
88    Map<String, Object> map = new LinkedHashMap<>();
89    map.put("count", 3);
90    map.put("greeting", "Hello, ");
91    map.put("system", System.class);
92
93    String template = ""
94        + "for (int i = 0; i < $count:L; i++) {\n"
95        + "  $system:T.out.println($greeting:S + list.get(i));\n"
96        + "}\n";
97
98    CodeBlock.Builder builder = CodeBlock.builder();
99    builder.addNamed(template, map);
100   ```
101
102 * New: `addJavadoc(CodeBlock)` overloads for TypeSpec, MethodSpec, and FieldSpec.
103 * New: `MethodSpec.addComment()` makes it easy to add a `// single-line comment.`
104 * New: `ClassName.getReflectionName()` returns a string like `java.util.Map$Entry`.
105 * Fix: Always write UTF-8. Previously JavaPoet would use the system default charset which was
106   potentially inconsistent across environments.
107 * Fix: Permit (constant) fields to be defined in annotation types.
108
109
110JavaPoet 1.7.0 *(2016-04-26)*
111-----------------------------
112
113 * New: Support parameterized types that enclose other types, like `Outer<String>.Inner`.
114 * New: `TypeName.isBoxedPrimitive()`.
115
116
117JavaPoet 1.6.1 *(2016-03-21)*
118-----------------------------
119
120 * Fix: Double quotes and backslashes in string literals were not properly quoted in 1.6.0. This is
121   now fixed.
122
123
124JavaPoet 1.6.0 *(2016-03-19)*
125-----------------------------
126
127 * New: Revive `CodeBlock.of()`, a handy factory method for building code blocks.
128 * New: Add `TypeSpec` factory methods that take a `ClassName`.
129 * New: `TypeName.annotated()` adds an annotation to a type.
130 * New: `TypeVariableName.withBounds()` adds bounds to a type variable.
131 * New: `TypeSpec.Builder.addInitializerBlock()` adds an instance initializer.
132 * Fix: Make `TypeSpec.Kind` enum public. This can be used to check if a `TypeSpec` is a class,
133   interface, enum, or annotation.
134 * Fix: Don’t break import resolution on annotated types.
135 * Fix: Forbid unexpected modifiers like `private` on annotation members.
136 * Fix: Deduplicate exceptions in `MethodSpec.Builder`.
137 * Fix: Treat `ErrorType` like a regular `DeclaredType` in `TypeName.get()`. This should make it
138   easier to write annotation processors.
139
140
141JavaPoet 1.5.1 *(2016-01-10)*
142-----------------------------
143
144 * Fix: Annotated `TypeName` instances are only equal if their annotations are equal.
145
146JavaPoet 1.5.0 *(2016-01-10)*
147-----------------------------
148
149 * New: `import static`! See `JavaFile.Builder.addStaticImport()` variants.
150 * New: Overload `NameAllocator.newName(String)` for creating a one-off name without a tag.
151 * Fix: AnnotationSpec escapes character literals properly.
152 * Fix: Don't stack overflow when `TypeVariableName` is part of `ParameterizedTypeName`.
153 * Fix: Reporting not used indexed arguments in like `add("$1S", "a", "b")`.
154 * Fix: Prevent import of types located in the default package, i.e. have no package name.
155
156
157JavaPoet 1.4.0 *(2015-11-13)*
158-----------------------------
159
160 * New: `AnnotationSpec.get(Annotation)`.
161 * New: Type annotations! `TypeName.annotated()` can attach annotations like `@Nullable` directly to
162   types. This works for both top-level types and type parameters as in `List<@Nullable String>`.
163 * New: `equals()` and `hashCode()` on `AnnotationSpec`, `CodeBlock`, `FieldSpec`, `JavaFile`,
164   `MethodSpec`, `ParameterSpec`, `TypeName`, and `TypeSpec`.
165 * New: `NameAllocator.clone()` to refine a NameAllocator for use in an inner scope code block.
166 * Fix: Don't stack overflow when `TypeVariableName` gets a self-referential type.
167 * Fix: Better handling of name collisions on imports. Previously JavaPoet did the wrong thing when
168   a referenced type and a nested types had the same name.
169
170
171JavaPoet 1.3.0 *(2015-09-20)*
172-----------------------------
173
174 * New: `NameAllocator` API makes it easy to declare non-conflicting names.
175 * New: Support annotations on enum values.
176 * Fix: Avoid infinite recursion in `TypeName.get(TypeMirror)`.
177 * Fix: Use qualified name for conflicting simple names in the same file.
178 * Fix: Better messages for parameter indexing errors.
179
180
181JavaPoet 1.2.0 *(2015-07-04)*
182-----------------------------
183
184 * New: Arguments may have positional indexes like `$1T` and `$2N`. Indexes can be used to refer to
185   the same argument multiple times in a single format string.
186 * New: Permit Javadoc on enum constants.
187 * New: Class initializer blocks with `addStaticBlock()`.
188 * Fix: `MethodSpec.overriding()` retains annotations.
189
190
191JavaPoet 1.1.0 *(2015-05-25)*
192-----------------------------
193
194 * New: Eager validation of argument types like `$T` and `$N`.
195 * New: `MethodSpec.varargs(boolean)` to generate varags methods.
196 * New: `AnnotationSpec.get()` and `MethodSpec.overriding()` to create annotations and methods from
197   the `javax.lang.model` API.
198 * New: `JavaFile.toJavaFileObject()`.
199 * New: Java 8 `DEFAULT` modifier.
200 * New: `toBuilder()` methods to build upon objects already constructed.
201 * New: Generate `@interface` annotation types.
202 * New: `TypeName.box()` and `TypeName.unbox()` convenience APIs.
203 * Fix: `nextControlFlow()` accepts arguments.
204 * Fix: Reject duplicate calls to set the superclass.
205 * Fix: `WildcardTypeName.get(WildcardType)` no longer throws a `NullPointerException`.
206 * Fix: Don't allow double field initialization.
207
208JavaPoet 1.0.0 *(2015-01-28)*
209-----------------------------
210
211 * This update is a complete rewrite. The project name is now `javapoet`. We renamed the it so you
212   can simultaneously use the old JavaWriter API and our new builder-based APIs in one project.
213 * Immutable value objects and builders. Instead of streaming the `.java` file from top to bottom,
214   you now define members in whatever way is convenient.
215 * We now use our own models for type names.
216 * Imports are now added automatically.
217
218
219JavaWriter 2.5.1 *(2014-12-03)*
220-------------------------------
221
222 * New: `StringLiteral` type which encapsulates the behavior of `stringLiteral`.
223 * Fix: Use canonical name when emitting a class import.
224 * Fix: Apply type compression to varargs and array types.
225 * Fix: Restore binary compatibility with pre-2.5 versions.
226
227
228JavaWriter 2.5.0 *(2014-04-18)*
229-------------------------------
230
231 * New: Methods in interfaces will always have no body declaration.
232 * New: Control flow begin declaration now supports String format arguments.
233 * Fix: Truncate any generic type when emitting constructors.
234 * Fix: Do not emit trailing whitespace after '=' at end-of-line.
235
236
237JavaWriter 2.4.0 *(2014-01-10)*
238-------------------------------
239
240 * New: Properly indent hanging lines in field initializers.
241 * New: `emitEnumValue` variant which exposes a boolean of whether the current value is the last.
242
243
244JavaWriter 2.3.1 *(2013-12-16)*
245-------------------------------
246
247 * Fix: Properly handle subpackages of `java.lang` in `compressType`.
248
249
250JavaWriter 2.3.0 *(2013-11-24)*
251-------------------------------
252
253 * New: Configurable indent level via `setIndent`.
254 * New: `beginConstructor` method is a semantically clearer alternative for constructors.
255 * New: `emitEnumValues` method emits a list of values followed by semicolon.
256 * `emitImports` now supports `Class` arguments directly.
257 * Previously-deprecated, `int`-based modifier methods have been removed.
258
259
260JavaWriter 2.2.1 *(2013-10-23)*
261-------------------------------
262
263 * Fix: Do not emit trailing whitespace for empty Javadoc lines.
264
265
266JavaWriter 2.2.0 *(2013-09-25)*
267-------------------------------
268
269 * `setCompressingTypes` controls whether types are emitted as fully-qualified or not.
270
271
272JavaWriter 2.1.2 *(2013-08-23)*
273-------------------------------
274
275 * Attempt to keep annotations on a single line.
276
277
278JavaWriter 2.1.1 *(2013-07-23)*
279-------------------------------
280
281 * Fix: `stringLiteral` now correctly handles escapes and control characters.
282
283
284JavaWriter 2.1.0 *(2013-07-15)*
285-------------------------------
286
287 * New: All methods now take a `Set` of `Modifier`s rather than an `int`. The `int` methods are
288   now deprecated for removal in JavaPoet 1.0.
289 * Annotations with a single "value" attribute will now omit the key.
290
291
292JavaWriter 2.0.1 *(2013-06-17)*
293-------------------------------
294
295 * Correct casing of `emitSingleLineComment`.
296
297
298JavaWriter 2.0.0 *(2013-06-06)*
299-------------------------------
300
301 * Package name is now `com.squareup.javawriter`.
302 * Support declaring `throws` clause on methods.
303
304
305JavaWriter 1.0.5 *(2013-05-08)*
306-------------------------------
307
308 * Fix: Fully qualify types whose simple name matches an import.
309
310
311JavaWriter 1.0.4 *(2013-03-15)*
312-------------------------------
313
314 * Fix: Static import emit now properly supports method imports.
315
316
317JavaWriter 1.0.3 *(2013-02-21)*
318-------------------------------
319
320 * Add support for emitting static imports.
321
322
323JavaWriter 1.0.2 *(2013-02-11)*
324-------------------------------
325
326 * Add `type` API for helping build generic types.
327 * Minor performance improvements.
328
329
330JavaWriter 1.0.1 *(2013-02-03)*
331-------------------------------
332
333 * Expose `compressType` API.
334
335
336JavaWriter 1.0.0 *(2013-02-01)*
337-------------------------------
338
339Initial release.
340