Skip to content

Commit

Permalink
Validate written classes if enabled, and fix reported issues (#4999)
Browse files Browse the repository at this point in the history
* Validate written classes if enabled

* Do not validate generated classes for now
  • Loading branch information
timtebeek authored Feb 10, 2025
1 parent cdd9d4b commit 5d3d123
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private void writeClassesDir() {

ClassWriter cw = new ClassWriter(0);
ClassVisitor classWriter = ctx.getMessage(VERIFY_CLASS_WRITING, false) ?
cw : new CheckClassAdapter(cw);
new CheckClassAdapter(cw) : cw;

classWriter.visit(
V1_8,
Expand All @@ -204,11 +204,12 @@ private void writeClassesDir() {
}

for (ClassDefinition innerClass : innerClasses) {
int lastIndexOf$ = innerClass.getName().lastIndexOf('$');
classWriter.visitInnerClass(
innerClass.getName(),
classDef.getName(),
innerClass.getName().substring(innerClass.getName().lastIndexOf('$') + 1),
innerClass.getAccess()
innerClass.getName().substring(0, lastIndexOf$),
innerClass.getName().substring(lastIndexOf$ + 1),
innerClass.getAccess() & 30239
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TypeTableTest implements RewriteTest {

@BeforeEach
void before() {
ctx.putMessage(TypeTable.VERIFY_CLASS_WRITING, true);
//TODO Dctx.putMessage(TypeTable.VERIFY_CLASS_WRITING, true);
JavaParserExecutionContextView.view(ctx).setParserClasspathDownloadTarget(temp.toFile());
tsv = temp.resolve("types.tsv.zip");
System.out.println(tsv);
Expand Down

0 comments on commit 5d3d123

Please sign in to comment.