Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -72,11 +72,10 @@ public boolean isEmpty() {
}

private int topLocal(CodeBuilder parent) {
return switch (parent) {
case BlockCodeBuilderImpl b -> b.topLocal;
case ChainedCodeBuilder b -> b.terminal.curTopLocal();
case TerminalCodeBuilder b -> b.curTopLocal();
};
if (parent instanceof BlockCodeBuilderImpl bcb) {
return bcb.topLocal;
}
return findTerminal(parent).curTopLocal();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -39,10 +39,8 @@ public final class ChainedClassBuilder
public ChainedClassBuilder(ClassBuilder downstream,
Consumer<ClassElement> consumer) {
this.consumer = consumer;
this.terminal = switch (downstream) {
case ChainedClassBuilder cb -> cb.terminal;
case DirectClassBuilder db -> db;
};
this.terminal = downstream instanceof ChainedClassBuilder ccb ?
ccb.terminal : (DirectClassBuilder) downstream;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,10 +38,8 @@ public final class ChainedFieldBuilder implements FieldBuilder {
public ChainedFieldBuilder(FieldBuilder downstream,
Consumer<FieldElement> consumer) {
this.consumer = consumer;
this.terminal = switch (downstream) {
case ChainedFieldBuilder cb -> cb.terminal;
case TerminalFieldBuilder tb -> tb;
};
this.terminal = downstream instanceof ChainedFieldBuilder cfb ?
cfb.terminal : (TerminalFieldBuilder) downstream;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -41,10 +41,8 @@ public final class ChainedMethodBuilder implements MethodBuilder {
public ChainedMethodBuilder(MethodBuilder downstream,
Consumer<MethodElement> consumer) {
this.consumer = consumer;
this.terminal = switch (downstream) {
case ChainedMethodBuilder cb -> cb.terminal;
case TerminalMethodBuilder tb -> tb;
};
this.terminal = downstream instanceof ChainedMethodBuilder cmb ?
cmb.terminal : (TerminalMethodBuilder) downstream;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,16 @@ private void inflateJumpTargets() {
//fallback to jump targets inflation without StackMapTableAttribute
for (int pos=codeStart; pos<codeEnd; ) {
var i = bcToInstruction(classReader.readU1(pos), pos);
switch (i) {
case BranchInstruction br -> br.target();
case DiscontinuedInstruction.JsrInstruction jsr -> jsr.target();
case LookupSwitchInstruction ls -> {
switch (i.opcode().kind()) {
case BRANCH -> ((BranchInstruction) i).target();
case DISCONTINUED_JSR -> ((DiscontinuedInstruction.JsrInstruction) i).target();
case LOOKUP_SWITCH -> {
var ls = (LookupSwitchInstruction) i;
ls.defaultTarget();
ls.cases();
}
case TableSwitchInstruction ts -> {
case TABLE_SWITCH -> {
var ts = (TableSwitchInstruction) i;
ts.defaultTarget();
ts.cases();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,10 +35,12 @@ public abstract sealed class NonterminalCodeBuilder implements CodeBuilder

public NonterminalCodeBuilder(CodeBuilder parent) {
this.parent = parent;
this.terminal = switch (parent) {
case NonterminalCodeBuilder cb -> cb.terminal;
case TerminalCodeBuilder cb -> cb;
};
this.terminal = findTerminal(parent);
}

static TerminalCodeBuilder findTerminal(CodeBuilder cob) {
return cob instanceof NonterminalCodeBuilder ncb ?
ncb.terminal : (TerminalCodeBuilder) cob;
}

@Override
Expand Down