Skip to content

Commit 712f8ed

Browse files
committed
Fixes class not found
I don’t understand why, but must be something to do with the way ByteBuddy works, the Advice class seems to be required to be a normal class, not an inner static class.
1 parent 4b29f6b commit 712f8ed

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/JabelJavacProcessor.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class JabelJavacProcessor implements Processor {
6969
static {
7070
// log that we've started, otherwise if there's certain types of errors, no output is seen at all from Jabel (e.g. errors compiling our code)
7171
// helps for verifying Jabel is being picked up correctly from project settings
72-
log.info("Jabel static initialising ByteBuddy");
72+
log.info("Jabel static initialising ByteBuddy 22");
7373

7474
ByteBuddyAgent.install();
7575
ByteBuddy byteBuddy = new ByteBuddy();
@@ -123,20 +123,6 @@ public class JabelJavacProcessor implements Processor {
123123
log.info("Jabel ByteBuddy initialisation complete");
124124
}
125125

126-
static public class PreviewFeatureCheckOverride {
127-
128-
/**
129-
* On {@link Preview#isPreview} exit, override the return value to always be false.
130-
*/
131-
@Advice.OnMethodExit
132-
static public boolean isPreview(Source.Feature feature) {
133-
log.debug("Feature being set to NOT preview: " + feature);
134-
return false;
135-
}
136-
}
137-
138-
139-
140126
@Override
141127
public SourceVersion getSupportedSourceVersion() {
142128
return SourceVersion.RELEASE_8;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.github.bsideup.jabel;
2+
3+
import com.sun.tools.javac.code.Preview;
4+
import com.sun.tools.javac.code.Source;
5+
import net.bytebuddy.asm.Advice;
6+
7+
public class PreviewFeatureCheckOverride {
8+
9+
static final boolean debug = false;
10+
11+
/**
12+
* On {@link Preview#isPreview} exit, override the return value to always be false.
13+
*/
14+
@Advice.OnMethodExit
15+
static public boolean isPreview(Source.Feature feature) {
16+
if (debug) {
17+
System.out.println("Feature being set to NOT preview: " + feature);
18+
}
19+
return false;
20+
}
21+
}

0 commit comments

Comments
 (0)