Skip to content
Permalink
Browse files
8275233: Incorrect line number reported in exception stack trace thro…
…wn from a lambda expression

Reviewed-by: jlahoda
  • Loading branch information
cushon committed Dec 7, 2021
1 parent 3955b03 commit d7c283a081c37bfb8bc5934e4b2af16cad512fd2
@@ -165,9 +165,14 @@ private LambdaToMethod(Context context) {
dumpLambdaToMethodStats = options.isSet("debug.dumpLambdaToMethodStats");
attr = Attr.instance(context);
forceSerializable = options.isSet("forceSerializable");
debugLinesOrVars = options.isSet(Option.G)
|| options.isSet(Option.G_CUSTOM, "lines")
|| options.isSet(Option.G_CUSTOM, "vars");
boolean lineDebugInfo =
options.isUnset(Option.G_CUSTOM) ||
options.isSet(Option.G_CUSTOM, "lines");
boolean varDebugInfo =
options.isUnset(Option.G_CUSTOM)
? options.isSet(Option.G)
: options.isSet(Option.G_CUSTOM, "vars");
debugLinesOrVars = lineDebugInfo || varDebugInfo;
verboseDeduplication = options.isSet("debug.dumpLambdaToMethodDeduplication");
deduplicateLambdas = options.getBoolean("deduplicateLambdas", true);
nestmateLambdas = Target.instance(context).runtimeUseNestAccess();
@@ -23,7 +23,7 @@


// key: compiler.note.verbose.l2m.deduplicate
// options: --debug=dumpLambdaToMethodDeduplication
// options: -g:none --debug=dumpLambdaToMethodDeduplication

import java.util.function.Function;

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2021, Google LLC. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test 8275233
* @summary Incorrect line number reported in exception stack trace thrown from a lambda expression
* @compile/ref=DeduplicationDebugInfo.out -XDrawDiagnostics -XDdebug.dumpLambdaToMethodDeduplication -g:none DeduplicationDebugInfo.java
* @compile/ref=DeduplicationDebugInfo_none.out -XDrawDiagnostics -XDdebug.dumpLambdaToMethodDeduplication DeduplicationDebugInfo.java
* @compile/ref=DeduplicationDebugInfo_none.out -XDrawDiagnostics -XDdebug.dumpLambdaToMethodDeduplication -g:lines DeduplicationDebugInfo.java
* @compile/ref=DeduplicationDebugInfo_none.out -XDrawDiagnostics -XDdebug.dumpLambdaToMethodDeduplication -g:vars DeduplicationDebugInfo.java
* @compile/ref=DeduplicationDebugInfo_none.out -XDrawDiagnostics -XDdebug.dumpLambdaToMethodDeduplication -g:lines,vars DeduplicationDebugInfo.java
*/

import java.util.function.Function;

class DeduplicationDebugInfoTest {
void f() {
Function<Object, Integer> f = x -> x.hashCode();
Function<Object, Integer> g = x -> x.hashCode();
}
}
@@ -0,0 +1 @@
DeduplicationDebugInfo.java:39:39: compiler.note.verbose.l2m.deduplicate: lambda$f$0(java.lang.Object)
@@ -93,6 +93,7 @@ public static void main(String[] args) throws Exception {
Arrays.asList(
"-d",
".",
"-g:none",
"-XDdebug.dumpLambdaToMethodDeduplication",
"-XDdebug.dumpLambdaToMethodStats"),
null,

1 comment on commit d7c283a

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on d7c283a Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.