Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch statement with yield and try/catch produces EmptyStackException #1394

Closed
felix-schoepf-esd opened this issue Sep 19, 2023 · 28 comments · Fixed by #1740
Closed

switch statement with yield and try/catch produces EmptyStackException #1394

felix-schoepf-esd opened this issue Sep 19, 2023 · 28 comments · Fixed by #1740
Assignees
Labels
bug Something isn't working regression Something was broken by a previous change
Milestone

Comments

@felix-schoepf-esd
Copy link

We wanted to upgrade to STS 4.20.0, which is based on Eclipse Platform 4.29.0 and includes Eclipse Java Development Tools 3.19.200. Unfortunately, after the update, we are running into the following error:

java.util.EmptyStackException
	at java.base/java.util.Stack.peek(Stack.java:103)
	at java.base/java.util.Stack.pop(Stack.java:85)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.popTypeBinding(CodeStream.java:7803)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.ireturn(CodeStream.java:5645)
	at org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.ireturn(StackMapFrameCodeStream.java:449)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.generateReturnBytecode(CodeStream.java:2593)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateReturnBytecode(ReturnStatement.java:257)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateCode(ReturnStatement.java:240)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:355)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:292)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:763)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:833)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:413)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1324)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:790)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1245)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:868)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider$1.run(CoreASTProvider.java:294)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider.createAST(CoreASTProvider.java:286)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider.getAST(CoreASTProvider.java:199)
	at org.eclipse.jdt.core.manipulation.SharedASTProviderCore.getAST(SharedASTProviderCore.java:138)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:166)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$1.run(SelectionListenerWithASTManager.java:151)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
eclipse.buildId=4.20.0.202309081654
java.version=20.0.2
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments:  -product org.springframework.boot.ide.branding.sts4 -product org.springframework.boot.ide.branding.sts4
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4 -data file:/D:/work/workspaces/sts4/sts-test/ -product org.springframework.boot.ide.branding.sts4

I tracked it down to an issue with a switch statement, a labeled expression, yield and try/catch. Similar to the following code example, which triggers the EmptyStackException as well:

	private static int switchWithYield() {
		String myStringNumber = "1";
		return switch (myStringNumber) {
		case "1" -> {
			try {
				yield Integer.parseInt(myStringNumber);
			} catch (NumberFormatException e) {
				throw new RuntimeException("Failed parsing number", e);
			}
		}
		default -> throw new IllegalArgumentException("Unexpected value: " + myStringNumber);
		};
	}

Compiler compliance level is 17.

The same code perfectly compiles with STS 4.19.0 based on Eclipse Platform 4.28.0 and and included Eclipse Java Development Tools 3.19.100.

@iloveeclipse iloveeclipse added bug Something isn't working regression Something was broken by a previous change labels Sep 19, 2023
@iloveeclipse
Copy link
Member

Still on master.

Complete example:

public class X {

	public static void main(String[] args) {
		switchWithYield("1");
		switchWithYield("42");
	}

	private static int switchWithYield(String myStringNumber) {
		return switch (myStringNumber) {
		case "1" -> {
			try {
				yield Integer.parseInt(myStringNumber);
			} catch (NumberFormatException e) {
				throw new RuntimeException("Failed parsing number", e);
			}
		}
		default -> throw new IllegalArgumentException("Unexpected value: " + myStringNumber);
		};
	}
}

Stack trace on master:

java.util.EmptyStackException
	at java.base/java.util.Stack.peek(Stack.java:101)
	at java.base/java.util.Stack.pop(Stack.java:83)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.popTypeBinding(CodeStream.java:7803)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.ireturn(CodeStream.java:5645)
	at org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.ireturn(StackMapFrameCodeStream.java:449)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.generateReturnBytecode(CodeStream.java:2593)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateReturnBytecode(ReturnStatement.java:257)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateCode(ReturnStatement.java:240)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:355)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:292)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:763)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:833)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:413)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1075)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1111)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:282)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:348)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:193)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:94)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:806)
	at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1325)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:132)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:94)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:91)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:158)
	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:94)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:107)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:78)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:207)

@jarthana
Copy link
Member

Will take a look if no takers found post Java 21.
Copying @mpalat also

@srikanth-sankaran srikanth-sankaran self-assigned this Sep 20, 2023
@MonsterDruide1
Copy link

MonsterDruide1 commented Sep 24, 2023

I'm also running into this. Interestingly, even removing the concatenation on the bottom error in default will work around this issue.
This will throw an exception:

public static Object bugReport(String val) {
		return switch(val) {
		case "whatever" -> {
			try {
				yield null;
			} catch(NumberFormatException e) {
				throw new RuntimeException(e);
			}
		}
		default -> {
			String concat = "Concat "+val;
			throw new RuntimeException(val);
		}
		};
	}

But this won't: (removing the concat-line)

public static Object bugReport(String val) {
		return switch(val) {
		case "whatever" -> {
			try {
				yield null;
			} catch(NumberFormatException e) {
				throw new RuntimeException(e);
			}
		}
		default -> {
			throw new RuntimeException(val);
		}
		};
	}

@srikanth-sankaran
Copy link
Contributor

@jarthana the mention of string concatenation makes me wonder if this may have something to do with the indified string catenation. Did we add a switch to retain the old behavior? If so it should be easy to verify if this is on the right track.

@jarthana
Copy link
Member

jarthana commented Sep 25, 2023

@jarthana the mention of string concatenation makes me wonder if this may have something to do with the indified string catenation. Did we add a switch to retain the old behavior? If so it should be easy to verify if this is on the right track.

Yes, it's CompilerOptions.OPTION_UseStringConcatFactory. Let me check with this code.

Edit: Indeed, disabling the option makes the error go away. Will check what's going on.

@srikanth-sankaran
Copy link
Contributor

@jarthana the mention of string concatenation makes me wonder if this may have something to do with the indified string catenation. Did we add a switch to retain the old behavior? If so it should be easy to verify if this is on the right track.

Yes, it's CompilerOptions.OPTION_UseStringConcatFactory. Let me check with this code.

Edit: Indeed, disabling the option makes the error go away. Will check what's going on.

Thanks Jay, I have reassigned this ticket to you.

@jarthana
Copy link
Member

It appears that now String concatenation involves an invoke dynamic is interfering with the changes around the popInvokeTypeBinding() and its invocation from invokeDynamic(). I don't know well how the CodeStream#switchSaveTypeBindings or containsSwitchWithTry are supposed to work. But I quickly checked disabling the latter before calling invokeDynamic() from invokeDynamicForStringConcat() fixes this. This can be a permanent fix unless Manoj or Conrad, who originally authored this, can confirm.

The other option could be to introduce another invoke* method that does not call popInvokeTypeBinding(), but instead calls popTypeBinding() so, the clients can choose the right one.

@jarthana
Copy link
Member

I have a draft patch. I don't really understand the isSwitchStackTrackingActive() checks inside the pop*() methods and don't want to mess with it much. What I seems to avoid all of it by simply switching off the flag when we generate the invoke dynamic for the switch concatenation. Feel free to review and comment. I will also wait for Manoj/Conrad to throw some light on isSwitchStackTrackingActive() and such.

@mpalat
Copy link
Contributor

mpalat commented Oct 5, 2023

I have a draft patch. I don't really understand the isSwitchStackTrackingActive() checks inside the pop*() methods and will also wait for Manoj/Conrad to throw some light on isSwitchStackTrackingActive() and such.

This is used to figure out whether we need to do the tracking at all - this is required only if we have a try inside a switch - this is determined early in the compilation phase

@srikanth-sankaran
Copy link
Contributor

We have another report here: #1727 - this is impacting multiple people, let us close this for M1.

@srikanth-sankaran srikanth-sankaran added this to the 4.31 M1 milestone Dec 12, 2023
@srikanth-sankaran
Copy link
Contributor

Smallest reproducing test case:

public class X {
	String foo() {
		String x = "1";
		return switch (x) {
		case "1" -> {
			try {
				yield x;
			} finally  {
				
			}
		}
		default -> throw new RuntimeException("" + x); 
		};
	}
}

@sbrannen
Copy link

@srikanth-sankaran, have you seen the potentially related issue I raised in #1686?

@srikanth-sankaran
Copy link
Contributor

It appears that now String concatenation involves an invoke dynamic is interfering with the changes around the popInvokeTypeBinding() and its invocation from invokeDynamic(). I don't know well how the CodeStream#switchSaveTypeBindings or containsSwitchWithTry are supposed to work. But I quickly checked disabling the latter before calling invokeDynamic() from invokeDynamicForStringConcat() fixes this. This can be a permanent fix unless Manoj or Conrad, who originally authored this, can confirm.

The other option could be to introduce another invoke* method that does not call popInvokeTypeBinding(), but instead calls popTypeBinding() so, the clients can choose the right one.

This is a red herring. I suspect the defect is in org.eclipse.jdt.internal.compiler.codegen.CodeStream.invokeDynamicForStringConcat(StringBuilder, List<TypeBinding>) in this call:

	this.invokeDynamic(invokeDynamicNumber,
			2, // <<<<----------------------------------------- Hardcoded argsSize
			1, // int
			ConstantPool.ConcatWithConstants,
			signature.toString().toCharArray(),
			TypeIds.T_JavaLangObject,
			getPopularBinding(ConstantPool.JavaLangStringConstantPoolName));

This hardcoded argsSize to be 2. I think it should be computed dynamically based on arguments of org.eclipse.jdt.internal.compiler.codegen.CodeStream.invokeDynamicForStringConcat(StringBuilder, List<TypeBinding>)

This results in one too many pops in the concerned test case.

@srikanth-sankaran
Copy link
Contributor

@srikanth-sankaran, have you seen the potentially related issue I raised in #1686?

Other than both cases having switch expressions, the underlying causes are very different. The current bug is about implementation of string concatenation using invoke dynamic. #1686 doesn't use string concatenation at all.

@srikanth-sankaran
Copy link
Contributor

basically the stack size computed may differ

@srikanth-sankaran : I see that in most cases maxstack value is increased in new classes by one or two. Looking at your change, I believe that should be expected, as it was hard-coded before and now can be higher. Classfile diffs are here.

I will start touching bundles later, have to finish some other work...

Sorry if I am chiming in late, but the stack size need not always increase. While in the remastered tests in https://github.com/eclipse-jdt/eclipse.jdt.core/pull/1740/files they only increase, that is a coincidence.

Consider this test case:

public class X {
  public static void main(String[] args) {
	  new X().foo(new String[] { "o", "n", "e", "!" });
  }
  public void goo(String ... ss) {}
  public void foo(String[] args) {
	  int one = 1;
	  String s = "one=" + args[0] + args[1] + args[2] + args[3];
	  goo("one=" + args[0] + args[1] + args[2] + args[3], s, s, s);
  }
}

When compiled with 4.30, stacksize of foo is 13 while with the fix here it becomes 11

@srikanth-sankaran
Copy link
Contributor

The key computation is this from org.eclipse.jdt.internal.compiler.codegen.CodeStream.invokeDynamic(int, int, int, char[], char[], boolean, TypeReference, TypeReference[], int, TypeBinding)

this.stackDepth += returnTypeSize - argsSize;  // line 1
if (this.stackDepth > this.stackMax) {
    this.stackMax = this.stackDepth;
}

where this.stackDepth is the depth of the operand stack now vs this.stackMax is the high water mark.

What line 1 doing is computing the operand stack depth as a result of the invoke dynamic operation. We are invoking the string concat bootstrap method after having loaded up the operands on the stack. The operation is going to pop argSize slots worth of operands, concatenate them and push the result on to the stack (returnTypeSize worth of slots on the stack)

Before the bug fix, argSize was getting passed a hardcoded incorrect constant value of 2. returnTypeSize is always 1 for string concat factory method since it would leave the concatenated string on the operand stack.

So before the bug fix

this.stackDepth += returnTypeSize - argsSize; 

was really boiling down to:

this.stackDepth += 1- 2; 

decrementing stackDepth by 1.

Now with the bug fix in place returnTypeSize continues to be 1 (one string result) but argument count can be 1, 2, 3, 4, 5, 6 ... depending upon the actual string concat operation (eg: for "one=" + args[0] + args[1] + args[2] + args[3] argSize is 4 as we concat at one stroke)

Accordingly the current stackDepth may increase relatively speaking when computed argSize is 1 (vs hardcoded 2) and will decrease relatively speaking when computed argSize is 3,4,5 etc (vs hardcoded 2) and will stay the same when computed value happens to be same hardcoded value

@srikanth-sankaran
Copy link
Contributor

@srikanth-sankaran : I see that in most cases maxstack value is increased in new classes by one or two.
Looking at your change, I believe that should be expected, as it was hard-coded before and now can be higher.

computed argSize can also be lower. It can be lower, higher or the same.

@srikanth-sankaran
Copy link
Contributor

Section 4.9.2 Structural Constraints of JVMS has this to say:

• At no point during execution can the operand stack grow to a depth greater than
that implied by the max_stack item.

So we should compute the right value and capture the right value - or else we risk a java.lang.ClassFormatError at runtime. (That said, JVMS may use this value computed by the compiler as a hint - I don't know)

@srikanth-sankaran
Copy link
Contributor

For curiosity's sakes, I instrumented ECJ to store 1 instead of the computed 2 for main's stack size in:

public class X {
	public static void main(String[] args) {
		System.out.println("Hello World!"); 
	}
}

Running it results in:

Error: Unable to initialize main class X
Caused by: java.lang.VerifyError: Operand stack overflow
Exception Details:
  Location:
    X.main([Ljava/lang/String;)V @3: ldc
  Reason:
    Exceeded max stack size.
  Current Frame:
    bci: @3
    flags: { }
    locals: { '[Ljava/lang/String;' }
    stack: { 'java/io/PrintStream' }
  Bytecode:
    0000000: b200 1012 16b6 0018 b1                 


noopur2507 pushed a commit that referenced this issue Dec 15, 2023
* Fix one too many pops arising from string concat invoke dynamic

* Fixes #1394
mpalat added a commit that referenced this issue Dec 19, 2023
* configure default output.. = bin/

* JavaSearchScope: improve encloses() performance  #474

* [test] remove outdated latestBREE project

* fix some ecj markers

Especially after moving files to compiler.batch - which has no resource
warnings - the @SuppressWarnings("resource") is not used - leading to a
marker

* Single async "Synchronizing projects" Job #419

Scheduling multiple times "while the job is running, the job will still
only be rescheduled once" (javadoc) so there will be always only a
single job running.
Using a Set prevents touching projects multiple times.

#419

Manually tested by changing Compiler Building options "Circular
dependencies", which triggers a new build.

* [test] fix AbstractJavaModelTests #1333

avoid asynchronous refresh. Implementation taken from
org.eclipse.core.tests.resources.refresh.RefreshProviderTest.joinAutoRefreshJobs()

#1333

* TestVerifier: never wait 100ms

improve test time, accurate timeout

* [performance] ClassFileReader: use already open Zip File

instead of creating new ZipFile instance.

also:
* use Files.readAllBytes
* removed unused code
* faster toUri avoiding isDirectory() check for the JARs which are known
to be no directory

improves performance of read() on windows by factor 2
tested with java reference search to java.lang.Object

* Stop skipping compare-with-baseline for jdt.annotation v2

One less thing that has to be manually tracked and done.

* Version bump for jdt.annotation

Pointed by
https://download.eclipse.org/eclipse/downloads/drops4/I20231130-0020/buildlogs/reporeports/reports/versionChecks.html

* Fix github urls in NOTICE file

* Use try-with-resource and enable warning if not

org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning

StringWriter does not need flush() or close() and can not throw
IOException.

Tests excluded.

To get rid of boiler plate code.

* version bumps

* [21] JEP 430 String Templates (#1513)

Grammar, compiler AST, resolution and code generation changes

* Javadoc: fix unclosed <code>

* break from loop within labeled block causes loss of nullness info (#1660)

fixes #1659

* Fixes incorrect Javadoc after StringBuffer to StringBuilder change

* NPE in ASTRewriteFlattener as return value of GuardedPattern.getPattern() is null  (#1647)

NPE in ASTRewriteFlattener as return value of
GuardedPattern.getPattern() is null

* Adding pomless build to JDT core

This enables pomless builds for JDT coreand removes the simple pom
files.

Future commits can reduce the usage of pom files further. This might
require enhancements in pomless builds to specify the test classes and
suites eclipse-tycho/tycho#3105

* Using Simplify lambda expression and method reference syntax cleanup on
core

Using the JDT UI "Simplify lambda expression and method reference
syntax" clean-up on jdt.core.

* Internal compiler error: ArrayIndexOutOfBoundsException in latest i build (#1664)


fixes #1661

* Using Simplify lambda expression and method reference syntax cleanup on
all plug-ins except core

Using the JDT UI "Simplify lambda expression and method reference
syntax" clean-up on all plug-ins except jdt.core.

* Using short-circuit in IncrementalImageBuilder

* Re-normalize line-endings in git of all files to Linux style ("\n")

Some files were checked-in into git having windows style line
endings (\r\n). This is in general not wanted because it can cause
modified files without any difference in git-staging on Windows if
auto-crlf is enabled.

To re-normalize line endings of all files use the following command
(including dot):

git add --renormalize .

* Bump bundle dependencies to trigger a rebuild / fix SDK build error

The change in bytecode of FullSourceWorkspaceBuildTests is due the
constant value change of
o.e.jdt.internal.compiler.parser.TerminalTokens.TokenNameEOF coming
from #1513.

Fixes eclipse-platform/eclipse.platform.releng.aggregator#1617

* False positive "Dead code" compiler error reported on org.eclipse.pde.internal.core.util.PDEJavaHelper.getExternalPackageFragment(String, String) (#1671)

fixes #1667

* Use diamond operator in jdt.core repo

Using the JDT UI clean-up, this removes the redundant type information.

Also activating
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
The rest of the changes in the prefs file were done by the tooling, not
by
selecting anther value.

* Improve constructor completions inside method invocations Fix #1587 (#1588)

* Try-with-resource clean-up in JDT core

Using the JDT UI try-with-resource clean-up on core.
Also manually inlining the declaration of multiple places into the try()
clause.

* Make inner classes static where possible in JDT core

Running the JDT performnace clean-up "Make inner classes static where
possible" in JDT core

* Use Use lazy logical operator (&& and ||)

Running the performance clean-up "Use lazy logical operator (&& and ||)"
on JDT core

* Using Integer.toString directly in Disassembler

It is also a JDT UI performance clean-up but this clean-up found only
one occurrence.

* use Path.of() to avoid 'Potential resource leak' warnings

* @NonNullByDefault does not work for type arguments of a local type (#1694)

fixes #1693

* ClassCastException during code completion on Annotation (#1696)

fixes #1440

Also fixes noise from #1662

* CompilationUnitResolver: Name the CU that causes Exception (#1690)

for example during Cleanup
eclipse-jdt/eclipse.jdt.ui#950

Co-authored-by: Jörg Kubitz <jkubitz-eclipse@gmx.de>

* Code selection support for String template expressions (#1699)

Fixes  #1685

* Report error if string template is used without preview option enabled (#1697)

Improves the fix for #544

* ECJ crashes when an embedded expression contains broken code (#1702)

Set haltOnSyntaxError when parsing for embedded expressions. Also using the correct delimiters for text blocks in printExpression() methods.

* Selection model tests for string templates (#1704)

* tests: enable discouragedReference=warning, declare x-friends

to get rid of warnings during build (does not respect the jdt
preferences)

* Javadoc format fixes

Contributes to
eclipse-platform/eclipse.platform.releng.aggregator#1531

* Performance: Add public API for Batch Reads in UI - closes #1614

During Batches:
* cache Zip Files
* enable JavaModelManager.temporaryCache

Also:
* uses Batch Reads during some core actions that benefit from it.
* adds trace logging when caching is missing.

#1614

* Javadoc format fixes (part 2)

Contributes to
eclipse-platform/eclipse.platform.releng.aggregator#1531.
It's a pity that this takes multiple cycles but fixing one thing from
the log uncovers the next.

* ECJ 3.36.0 regression: The type 'E extends java.lang.Exception' is not a valid substitute for the type parameter 'E extends java.lang.@nonnull Exception' (#1708)

fixes #1691

+ also slightly updates NullAnnotationTests18 as NullAnnotationTests21

* Implement support for code completion inside embedded expression of (only) string templates (not text block templates) (#1712)

* Implement support for code completion inside embedded expression of
(only) string templates (not text block templates)

* Fixes #1711

* Fixes #1641 (#1713)

* Add new testcase #1701 (#1705)

* Content assist does not propose overrides in records (#1718)

* Fixes #1095

* JavaModelManager: lazy initialize TouchJob #1720

#1720

* Run the JavaCoreStandaloneTest in the build

#1720

* Bogus error about return expression involving pattern matching (#1731)

Fixes #1726

* Compiler fails to recognize an exhaustive switch (#1733)

*  Fixes #1725

* [21] Processed string templates falsely contain backslash characters (#1730)

#1719

* 1641_enum_further_fixes (#1739)

* Fix one too many pops arising from string concat invoke dynamic (#1740)

* Fix one too many pops arising from string concat invoke dynamic

* Fixes #1394

* Wrong placement of exception range closure results in AIOOB (#1744)

Fixes #1686

* Improper warning - Potential null pointer access (#1469)

Fixes #1461
Sets the flow info reach mode to FlowInfo.UNREACHABLE_BY_NULLANALYSIS
after 'Object o = null;if (Objects.isNull(o)) return;', 'Object o = "";if (Objects.nonNull(o)) return;

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>

* Touch bundles affected by the changed ecj version

See #1394
See eclipse-platform/eclipse.platform.releng.aggregator#1659

* Upload eventfile and unit test results

* 2023-06->2023-09 Seems to have broke dependency graph management in our project (#1698)

* Add test for reproducing #1654
* Fix to make that test pass

---------

Co-authored-by: Stephan Herrmann <stephan.herrmann@berlin.de>

* [memory] SoftReference for ResourceCompilationUnit.contents #1743

Ability to reduce memory during searches that find many files

#1743

* deduplicate "eclipse" #1743

CharDeduplication was not designed to deduplicate tokens with length 7+
which could lead to high memory consumption. With this change tokens of
all sizes can be deduplicated.

#1743

A benchmark implemented in CharDeduplicationTest.main(String[]) shows
the new deduplication is performed at similar speed (.21s instead of
.16s) but deduplicates much more tokens (99% instead of 36%).

* 1703.constant definitions (#1756)

* Fixes [21] AIOOB at switchStatement TNode.addPattern  (#1757)

org.eclipse.jdt.internal.compiler.ast.SwitchStatement $TNode.addPattern

---------

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
Co-authored-by: Jörg Kubitz <jkubitz-eclipse@gmx.de>
Co-authored-by: Eric Milles <eric.milles@thomsonreuters.com>
Co-authored-by: Александър Куртаков <akurtakov@gmail.com>
Co-authored-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Co-authored-by: Stephan Herrmann <stephan.herrmann@berlin.de>
Co-authored-by: Lars Vogel <Lars.Vogel@vogella.com>
Co-authored-by: Suby S Surendran <suby.surendran@ibm.com>
Co-authored-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Co-authored-by: Andrey Loskutov <loskutov@gmx.de>
Co-authored-by: Gayan Perera <gayanper@gmail.com>
Co-authored-by: Jörg Kubitz <51790620+jukzi@users.noreply.github.com>
Co-authored-by: Srikanth Sankaran <131454720+srikanth-sankaran@users.noreply.github.com>
Co-authored-by: Ed Merks <ed.merks@gmail.com>
Co-authored-by: Snjeza <snjezana.peco@redhat.com>
Co-authored-by: Christoph Läubrich <laeubi@laeubi-soft.de>
Co-authored-by: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
rgrunber pushed a commit to eclipse-jdtls/eclipse-jdt-core-incubator that referenced this issue Jan 9, 2024
…pse-jdt#1740)

* Fix one too many pops arising from string concat invoke dynamic

* Fixes eclipse-jdt#1394
rgrunber pushed a commit to eclipse-jdtls/eclipse-jdt-core-incubator that referenced this issue Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment