Skip to content

Instantly share code, notes, and snippets.

@cb372
Created July 16, 2012 15:05
Show Gist options
  • Save cb372/3123204 to your computer and use it in GitHub Desktop.
Save cb372/3123204 to your computer and use it in GitHub Desktop.
Project Lombok bug 399 - @ExtensionMethod fails unless extensions class is in root package
package com.github.cb372.lombok; // <-- Note: not the root package
import lombok.experimental.ExtensionMethod;
@ExtensionMethod({ Extensions.class })
public class Main {
public static void main(String[] args) {
System.out.println("Hello, %s".format("World.")); // => "Hello, World."
}
}
class Extensions {
public static String format(String format, Object ... args) {
return String.format(format, args);
}
}
/*
* javac:
*
* error: cannot find symbol
* symbol : variable com.github.cb372.lombok.Extensions
* location: class com.github.cb372.lombok.Main
*/
/*
* Cause: http://code.google.com/p/projectlombok/issues/detail?id=399
* Fix: https://github.com/rzwitserloot/lombok/commit/06826342f3be58cfb422f291f89e29be2cfde7f0
*/
// <-- Note: root package
import lombok.experimental.ExtensionMethod;
@ExtensionMethod({ Extensions.class })
public class Main {
public static void main(String[] args) {
System.out.println("Hello, %s".format("World.")); // => "Hello, World."
}
}
class Extensions {
public static String format(String format, Object ... args) {
return String.format(format, args);
}
}
/*
* Compiles fine with javac.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment