mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 14:16:11 +00:00
[issue #2039] update docs to warn about a javac peculiarity for named static imports.
This commit is contained in:
1 parent
4401562b8f
commit
46b71c810c
3 files changed
+7
-1
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Project Lombok Authors.
|
||||
* Copyright (C) 2015-2019 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,6 +33,8 @@ import java.lang.annotation.Target;
|
||||
* <li>It is marked final.</li>
|
||||
* <li>If any constructors are declared in it, an error is generated. Otherwise, a private no-args constructor is generated; it throws a {@code UnsupportedOperationException}.</li>
|
||||
* <li>All methods, inner classes, and fields in the class are marked static.</li>
|
||||
* <li><em>WARNING:</em> Do not use non-star static imports to import these members; javac won't be able to figure it out. Use either:
|
||||
* <code>import static ThisType.*;</code> or don't static-import.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
|
||||
@@ -183,6 +183,8 @@ public class JacksonExample {
|
||||
The initializer on a <code>@Builder.Default</code> field is removed and stored in a static method, in order to guarantee that this initializer won't be executed at all if a value is specified in the build. This does mean the initializer cannot refer to <code>this</code>, <code>super</code> or any non-static member. If lombok generates a constructor for you, it'll also initialize this field with the initializer.
|
||||
</p><p>
|
||||
Various well known annotations about nullity cause null checks to be inserted and will be copied to parameter of the builder's 'setter' method. See <a href="/features/GetterSetter">Getter/Setter</a> documentation's small print for more information.
|
||||
</p><p>
|
||||
Due to a peculiar way javac processes static imports, trying to do a non-star static import of the static <code>builder()</code> method won't work. Either use a star static import: `import static TypeThatHasABuilder.*;` or don't statically import the <code>builder</code> method.
|
||||
</p>
|
||||
</@f.smallPrint>
|
||||
</@f.scaffold>
|
||||
@@ -39,6 +39,8 @@
|
||||
<@f.smallPrint>
|
||||
<p>
|
||||
There isn't currently any way to create non-static members, or to define your own constructor. If you want to instantiate the utility class, even only as an internal implementation detail, <code>@UtilityClass</code> cannot be used.
|
||||
</p><p>
|
||||
Due to a peculiar way javac processes static imports, trying to do a non-star static import of any of the members of a `@UtilityClass` won't work. Either use a star static import: `import static TypeMarkedWithUtilityClass.*;` or don't statically import any of the members.
|
||||
</p>
|
||||
</@f.smallPrint>
|
||||
</@f.scaffold>
|
||||
Reference in new issue
Block a user