From patchwork Fri Feb 3 23:23:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Rybak X-Patchwork-Id: 13128522 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA2D1C61DA4 for ; Fri, 3 Feb 2023 23:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232956AbjBCXXv (ORCPT ); Fri, 3 Feb 2023 18:23:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbjBCXXt (ORCPT ); Fri, 3 Feb 2023 18:23:49 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCC0A56C9 for ; Fri, 3 Feb 2023 15:23:45 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id cw4so6552415edb.13 for ; Fri, 03 Feb 2023 15:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O2gJN58XYrIXV6frkqmIifi2QOO4FjIp8US0PDm+Bnc=; b=VEG9ewht7/XOQbkbMH8x1Htq4YDApkfSHXIYKvHUbyDDKiODS38PdEZVDH+zT1/c3R XCHkKY5+ypZvJ1Ot8lAszcosTn0NDTzUT7ADQOhMRZtL6zNP73oJ7NQc5PNwLbmoiCYJ MdeawHAeRG5u68lNZX6s5pohfqnXhyjZXFcvrkkO/l3TjU3vM3HRqjZwCWRkJP2RzrN9 Q3eSTx+Nfn4nSgqnStOn8dPIuIs+AOqUvev6AcNUmpp6W5KlAkuSxedaTjduGE32UHfO G+wtIkRYjmlpy6LvqKc3BPMnCi34fAshMvHMvWUtn4DGyuY6M/pAdsptkP5TFeIJcDLk dDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O2gJN58XYrIXV6frkqmIifi2QOO4FjIp8US0PDm+Bnc=; b=zWltOSovSjH0VISVtz7j1Dr2ssfl1++wR2SjhO1tBsE8BJ1Wid/kI0B74O5ehKN8I0 xy7Uk2Ik6NQ3mCOD5bq/Q193qkMGaRBAZGAD1Y5OtCc5JlNckA0TxBxgdIAwDsEbeH1j WTO2nfpIxZe0SjZtlSKL4s5LmX8CPIPuN6kLR3olIFEMEenNMmvRqR3Zv66rCyJwB+aG FGKAaVcily3tBem7dYxRsRCMcQhHPh+UcgTQD2JDgHr4FeWfBVRorQFItUw3ofreaJv/ /mjBCweFfLQiPH9zKz1FKXx3E0ANyTdwOtxIW3vZ+7GRV6hYVDVlI3V0FE+kCYIGFD3O D7Ow== X-Gm-Message-State: AO0yUKVWhymVk5FDUv+sIdaGcjYtvU1A8nGbKKVDJS+AFkmcOFfJuseC yHYITxuEnpmZ6WPUTprIwOCI0LrLMgdalb2YBzA= X-Google-Smtp-Source: AK7set9rMvuhzMWsXeR47fKKh5gjuBFhxBuyJtENAI7oeQctZC2HvIXLIlXiL9vRh/B1utPDF2A3Hw== X-Received: by 2002:a05:6402:1c87:b0:499:376e:6b35 with SMTP id cy7-20020a0564021c8700b00499376e6b35mr9804676edb.25.1675466623418; Fri, 03 Feb 2023 15:23:43 -0800 (PST) Received: from titov.fritz.box ([216.24.213.52]) by smtp.gmail.com with ESMTPSA id u4-20020aa7db84000000b0049f88f00f70sm1787917edt.7.2023.02.03.15.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 15:23:42 -0800 (PST) From: Andrei Rybak To: git@vger.kernel.org Cc: Jeff King , Paolo Bonzini , Johannes Sixt , Tassilo Horn Subject: [PATCH v1 1/3] userdiff: support Java type parameters Date: Sat, 4 Feb 2023 00:23:37 +0100 Message-Id: <20230203232339.216592-2-rybak.a.v@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203232339.216592-1-rybak.a.v@gmail.com> References: <20230203232339.216592-1-rybak.a.v@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A class or interface in Java [1] can have type parameters immediately following the name in the declaration, surrounded by angle brackets (paired less than and greater than signs).[2] Example of a class with type parameters "A" and "N": public class ParameterizedClass { private A field1; private N field2; } Support matching a parameterized class or interface declaration with type parameters immediately following the name of the type in the builtin userdiff pattern for Java. Do so by just allowing matching the first character after the name of the type to "<". An alternative approach could be to match both the opening and the closing angle brackets and matching the content between them in various ways. Just use the simpler regex for now. [1] Since Java 5 released in 2004. [2] Detailed description is available in the Java Language Specification, sections "Type Variables" and "Parameterized Types": https://docs.oracle.com/javase/specs/jls/se17/html/jls-4.html#jls-4.4 Signed-off-by: Andrei Rybak --- t/t4018/java-class-type-parameters | 6 ++++++ t/t4018/java-class-type-parameters-implements | 6 ++++++ t/t4018/java-interface-type-parameters | 6 ++++++ t/t4018/java-interface-type-parameters-extends | 6 ++++++ userdiff.c | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 t/t4018/java-class-type-parameters create mode 100644 t/t4018/java-class-type-parameters-implements create mode 100644 t/t4018/java-interface-type-parameters create mode 100644 t/t4018/java-interface-type-parameters-extends diff --git a/t/t4018/java-class-type-parameters b/t/t4018/java-class-type-parameters new file mode 100644 index 0000000000..579aa7af21 --- /dev/null +++ b/t/t4018/java-class-type-parameters @@ -0,0 +1,6 @@ +class RIGHT { + static int ONE; + static int TWO; + static int THREE; + private A ChangeMe; +} diff --git a/t/t4018/java-class-type-parameters-implements b/t/t4018/java-class-type-parameters-implements new file mode 100644 index 0000000000..b8038b1866 --- /dev/null +++ b/t/t4018/java-class-type-parameters-implements @@ -0,0 +1,6 @@ +class RIGHT implements List { + static int ONE; + static int TWO; + static int THREE; + private A ChangeMe; +} diff --git a/t/t4018/java-interface-type-parameters b/t/t4018/java-interface-type-parameters new file mode 100644 index 0000000000..a4baa1ae68 --- /dev/null +++ b/t/t4018/java-interface-type-parameters @@ -0,0 +1,6 @@ +interface RIGHT { + static int ONE; + static int TWO; + static int THREE; + public B foo(A ChangeMe); +} diff --git a/t/t4018/java-interface-type-parameters-extends b/t/t4018/java-interface-type-parameters-extends new file mode 100644 index 0000000000..31d7fb3244 --- /dev/null +++ b/t/t4018/java-interface-type-parameters-extends @@ -0,0 +1,6 @@ +interface RIGHT extends Function { + static int ONE; + static int TWO; + static int THREE; + public B foo(A ChangeMe); +} diff --git a/userdiff.c b/userdiff.c index d71b82feb7..759e22ffff 100644 --- a/userdiff.c +++ b/userdiff.c @@ -171,7 +171,7 @@ PATTERNS("html", PATTERNS("java", "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" /* Class, enum, and interface declarations */ - "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface)[ \t]+[A-Za-z][A-Za-z0-9_$]*[ \t]+.*)$\n" + "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface)[ \t]+[A-Za-z][A-Za-z0-9_$]*([ \t]+|<).*)$\n" /* Method definitions; note that constructor signatures are not */ /* matched because they are indistinguishable from method calls. */ "^[ \t]*(([A-Za-z_<>&][][?&<>.,A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", From patchwork Fri Feb 3 23:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Rybak X-Patchwork-Id: 13128523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BACACC05027 for ; Fri, 3 Feb 2023 23:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbjBCXXx (ORCPT ); Fri, 3 Feb 2023 18:23:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbjBCXXt (ORCPT ); Fri, 3 Feb 2023 18:23:49 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69233A58DB for ; Fri, 3 Feb 2023 15:23:46 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id z11so6622670ede.1 for ; Fri, 03 Feb 2023 15:23:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BbZq5firGddkAkNT9+2+N3pL53e1DAOsm6pG0PlKNhQ=; b=MMFj+8ORw4KnE/VLaah2HIA/AEdW5pwT62yMMa4rfE4/vBD9UHQT1Ej0tc/4yr+7Ml L20Yq958fh8DQeknwAEdXAVFrGBC1UYWXrR2opxWjAIVJc9DCBNWwZFYVQLLomJsB3sg rtjPOELruc4oPvWl1rJTkBNAabdeoa0nknXiGxYkM80KFxMlSiY3SqJ/XaC7XpBU6G9E LcbvdBnSxVq9BOXkpkF7eZgLXo7xXEyqGFvvC62hGwe26YwXs2IZ9Py+vTIFJqxiMD9w gGzeMwgaTuf0Rw3+koge4Uz4pWBzOqXcuwN1gSwrTcpOYqZ40JhekQzqN0Da2SFxkGJ4 DqCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BbZq5firGddkAkNT9+2+N3pL53e1DAOsm6pG0PlKNhQ=; b=ak/Q9vyTTR8nNqG8yjKjwPt26CgH6MYZ1XPCpeAA0/jpg1vEQS8S2yLG1FrLViv632 phj/foNxocKIYRKTxumfFnY+jnnJ5ql+5El1sBOgL8nhpKhe+VAyLQ69TUegTEaH4Kor Lw/9lc4Gv/17L7kxszlm9VsLvuFzr2T+mTqukXdGeGyR0JSPMs65lgxs+YAHL1DubNWM uaGAk7Xa8c9gEkk5FQgFvFv6/XxFsc5cNz+eV4/oI/hXcg6gIQMxeZu8weEsk0wsAiat FXIBVeC16umkoe1XwOlBh0XbcWswRv6MlJ5caZ1UQhKR49pugQAP1rlfcxjSHI6RD78x uUDg== X-Gm-Message-State: AO0yUKWdU5XZYguTQYikwRt2fo3fXhO3MQpscDPtMfe/87++wUGPncpF 6Io/EpbbcCJFXfwBq5OWk1+sylpSVl0LdSG6dBw= X-Google-Smtp-Source: AK7set9qzJsETcsa+E1iZtxRt92GDRbVdqmMmVczp+GrWDwMo8/r0vt68ip/MUPvGyeHdTsymYviZA== X-Received: by 2002:a05:6402:336:b0:4a2:449a:9498 with SMTP id q22-20020a056402033600b004a2449a9498mr12152181edw.31.1675466624707; Fri, 03 Feb 2023 15:23:44 -0800 (PST) Received: from titov.fritz.box ([216.24.213.52]) by smtp.gmail.com with ESMTPSA id u4-20020aa7db84000000b0049f88f00f70sm1787917edt.7.2023.02.03.15.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 15:23:43 -0800 (PST) From: Andrei Rybak To: git@vger.kernel.org Cc: Jeff King , Paolo Bonzini , Johannes Sixt , Tassilo Horn Subject: [PATCH v1 2/3] userdiff: support Java record types Date: Sat, 4 Feb 2023 00:23:38 +0100 Message-Id: <20230203232339.216592-3-rybak.a.v@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203232339.216592-1-rybak.a.v@gmail.com> References: <20230203232339.216592-1-rybak.a.v@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A new kind of class was added in Java 16 -- records.[1] The syntax of records is similar to regular classes with one important distinction: the name of the record class is followed by a mandatory list of components. The list is enclosed in parentheses, it may be empty, and it may immediately follow the name of the class or type parameters, if any, without separating whitespace. Code examples: public record Example(int i, String s) { } public record WithTypeParameters(A a, B b, String s) { } Support records in the builtin userdiff pattern for Java. Add "record" to the alternatives of keywords for kinds of class, and match an opening parenthesis as the first character right after the type name. An alternative approach could be to have an optional group that would match both the opening and the closing parentheses with some way of matching the declarations of the components. Just use the simpler regular expression for now. [1] detailed description is available in "JEP 395: Records" https://openjdk.org/jeps/395 Signed-off-by: Andrei Rybak --- t/t4018/java-record | 6 ++++++ t/t4018/java-record-type-parameters | 6 ++++++ userdiff.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 t/t4018/java-record create mode 100644 t/t4018/java-record-type-parameters diff --git a/t/t4018/java-record b/t/t4018/java-record new file mode 100644 index 0000000000..97aa819dd8 --- /dev/null +++ b/t/t4018/java-record @@ -0,0 +1,6 @@ +public record RIGHT(int comp1, double comp2, String comp3) { + static int ONE; + static int TWO; + static int THREE; + static int ChangeMe; +} diff --git a/t/t4018/java-record-type-parameters b/t/t4018/java-record-type-parameters new file mode 100644 index 0000000000..f62a035cc8 --- /dev/null +++ b/t/t4018/java-record-type-parameters @@ -0,0 +1,6 @@ +public record RIGHT(A comp1, N comp2, int comp3) { + static int ONE; + static int TWO; + static int THREE; + static int ChangeMe; +} diff --git a/userdiff.c b/userdiff.c index 759e22ffff..f92b3029aa 100644 --- a/userdiff.c +++ b/userdiff.c @@ -171,7 +171,7 @@ PATTERNS("html", PATTERNS("java", "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" /* Class, enum, and interface declarations */ - "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface)[ \t]+[A-Za-z][A-Za-z0-9_$]*([ \t]+|<).*)$\n" + "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface|record)[ \t]+[A-Za-z][A-Za-z0-9_$]*([ \t]+|[<(]).*)$\n" /* Method definitions; note that constructor signatures are not */ /* matched because they are indistinguishable from method calls. */ "^[ \t]*(([A-Za-z_<>&][][?&<>.,A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", From patchwork Fri Feb 3 23:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Rybak X-Patchwork-Id: 13128524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67B15C63797 for ; Fri, 3 Feb 2023 23:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233039AbjBCXXy (ORCPT ); Fri, 3 Feb 2023 18:23:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232835AbjBCXXu (ORCPT ); Fri, 3 Feb 2023 18:23:50 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776AFA58DC for ; Fri, 3 Feb 2023 15:23:47 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id n6so6595458edo.9 for ; Fri, 03 Feb 2023 15:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wj7nxpqbORoWXgKXiDDlC/dI2+jyuhxeXNPC7Or10Zw=; b=BbiSGgSKFMRUXZ/2EcLl43ZdyxmYsFkXkOnckoyHcFY2hWO8QP1Ua+NFRTe/JR5ZOu vTiKsayneH33tb12YaAmY+aFwjPaDUhPossPnL5312JedAPzbwZWYOagc+zJEqON1aC4 hhtetgZFZMft4t1l3fdllTJDy6wgX8Pr4IpiX2WHOn3d95rcD6qAhOx2tjN4Tzc/u2Gh j3JzLui78kHBAscDZAe4tbVq81YJUxzCRE8JUy7n0dQJmI0+/SMHjCXfeS9dVnnXxnB6 xOYqpTwq/V0Lyeh6LBLfeGlZ6aPi8p3mlF+gdZQiIMsNvpRpEGHemsB2skGCSFNn4C7l hoFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wj7nxpqbORoWXgKXiDDlC/dI2+jyuhxeXNPC7Or10Zw=; b=U6bKVtQmEetEr/R8DlKM+Qo0VQnX3r14/V1AdR0enrPtKvS2NuKOlf16YOmxScRWgP NSpAg8mz4Gg6bM5LWI/VV5iTRITF0+THPK4z+tS/TAX4SzGL8oBYsDSl21BLVeW4chlj 0mNOC0KSl56RfLJB9k/jzxfXkYKpozYM/T0V/6mmRY8nQjCjRfXTa2w+i+3hWCm8+oam bxR0ayelY/KKfNehAYUWjOikgd+I0ya56ZpMtPnIA5PQazrt5OlyAK+7weAq9ST8hOGf L0xtCpUIge3XtE/5d98Qti3N1U1xD+JKZvUoGF8LOgtqwT5l8/Errxj1BHYJz0dnld8C DQMg== X-Gm-Message-State: AO0yUKXkJExsAVwzUHtLY4SVpqxe32rYQFZeXhvmbT9HVBn5H+hGclpT jwZ2pJ2c3xbcKL1sFL+Ue6nb4mBNmprrT0f1DUM= X-Google-Smtp-Source: AK7set9hal6Gut2Wqczo+ilvitcHBGDXOpt964JuEGBkW4Z4Hxof+qgs/f4gtdEpS4IdFj4AJH6Trw== X-Received: by 2002:a05:6402:448c:b0:4a0:e31a:434 with SMTP id er12-20020a056402448c00b004a0e31a0434mr12120944edb.27.1675466625681; Fri, 03 Feb 2023 15:23:45 -0800 (PST) Received: from titov.fritz.box ([216.24.213.52]) by smtp.gmail.com with ESMTPSA id u4-20020aa7db84000000b0049f88f00f70sm1787917edt.7.2023.02.03.15.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 15:23:45 -0800 (PST) From: Andrei Rybak To: git@vger.kernel.org Cc: Jeff King , Paolo Bonzini , Johannes Sixt , Tassilo Horn Subject: [PATCH v1 3/3] userdiff: support Java sealed classes Date: Sat, 4 Feb 2023 00:23:39 +0100 Message-Id: <20230203232339.216592-4-rybak.a.v@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203232339.216592-1-rybak.a.v@gmail.com> References: <20230203232339.216592-1-rybak.a.v@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A new kind of class was added in Java 17 -- sealed classes.[1] This feature includes several new keywords that may appear in a declaration of a class. New modifiers before name of the class: "sealed" and "non-sealed", and a clause after name of the class marked by keyword "permits". The current set of regular expressions in userdiff.c already allows the modifier "sealed" and the "permits" clause, but not the modifier "non-sealed", which is the first hyphenated keyword in Java.[2] Allow hyphen in the words that precede the name of type to match the "non-sealed" modifier. In new input file "java-sealed" for the test t4018-diff-funcname.sh, use a Java code comment for the marker "RIGHT". This workaround is needed, because the name of the sealed class appears on the line of code that has the "ChangeMe" marker. [1] Detailed description in "JEP 409: Sealed Classes" https://openjdk.org/jeps/409 [2] "JEP draft: Keyword Management for the Java Language" https://openjdk.org/jeps/8223002 Signed-off-by: Andrei Rybak --- t/t4018/java-non-sealed | 8 ++++++++ t/t4018/java-sealed | 7 +++++++ t/t4018/java-sealed-permits | 6 ++++++ t/t4018/java-sealed-type-parameters | 6 ++++++ t/t4018/java-sealed-type-parameters-implements-permits | 6 ++++++ t/t4018/java-sealed-type-parameters-permits | 6 ++++++ userdiff.c | 2 +- 7 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 t/t4018/java-non-sealed create mode 100644 t/t4018/java-sealed create mode 100644 t/t4018/java-sealed-permits create mode 100644 t/t4018/java-sealed-type-parameters create mode 100644 t/t4018/java-sealed-type-parameters-implements-permits create mode 100644 t/t4018/java-sealed-type-parameters-permits diff --git a/t/t4018/java-non-sealed b/t/t4018/java-non-sealed new file mode 100644 index 0000000000..f68ffd4ff3 --- /dev/null +++ b/t/t4018/java-non-sealed @@ -0,0 +1,8 @@ +public sealed abstract class SealedClass { + public static non-sealed class RIGHT extends SealedClass { + static int ONE; + static int TWO; + static int THREE; + private int ChangeMe; + } +} diff --git a/t/t4018/java-sealed b/t/t4018/java-sealed new file mode 100644 index 0000000000..e722fee803 --- /dev/null +++ b/t/t4018/java-sealed @@ -0,0 +1,7 @@ +public sealed abstract class Sealed { // RIGHT + static int ONE; + static int TWO; + static int THREE; + public final class ChangeMe extends Sealed { + } +} diff --git a/t/t4018/java-sealed-permits b/t/t4018/java-sealed-permits new file mode 100644 index 0000000000..8573f2a7e8 --- /dev/null +++ b/t/t4018/java-sealed-permits @@ -0,0 +1,6 @@ +public sealed abstract class RIGHT permits PermittedA, PermittedB { + static int ONE; + static int TWO; + static int THREE; + private int ChangeMe; +} diff --git a/t/t4018/java-sealed-type-parameters b/t/t4018/java-sealed-type-parameters new file mode 100644 index 0000000000..ec31115961 --- /dev/null +++ b/t/t4018/java-sealed-type-parameters @@ -0,0 +1,6 @@ +public sealed abstract class RIGHT { + static int ONE; + static int TWO; + static int THREE; + private int ChangeMe; +} diff --git a/t/t4018/java-sealed-type-parameters-implements-permits b/t/t4018/java-sealed-type-parameters-implements-permits new file mode 100644 index 0000000000..9fd4dd5633 --- /dev/null +++ b/t/t4018/java-sealed-type-parameters-implements-permits @@ -0,0 +1,6 @@ +public sealed abstract class RIGHT implements List permits PermittedA, PermittedB { + static int ONE; + static int TWO; + static int THREE; + private int ChangeMe; +} diff --git a/t/t4018/java-sealed-type-parameters-permits b/t/t4018/java-sealed-type-parameters-permits new file mode 100644 index 0000000000..6af2352e46 --- /dev/null +++ b/t/t4018/java-sealed-type-parameters-permits @@ -0,0 +1,6 @@ +public sealed abstract class RIGHT permits PermittedA, PermittedB { + static int ONE; + static int TWO; + static int THREE; + private int ChangeMe; +} diff --git a/userdiff.c b/userdiff.c index f92b3029aa..040deb7439 100644 --- a/userdiff.c +++ b/userdiff.c @@ -171,7 +171,7 @@ PATTERNS("html", PATTERNS("java", "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" /* Class, enum, and interface declarations */ - "^[ \t]*(([a-z]+[ \t]+)*(class|enum|interface|record)[ \t]+[A-Za-z][A-Za-z0-9_$]*([ \t]+|[<(]).*)$\n" + "^[ \t]*(([a-z-]+[ \t]+)*(class|enum|interface|record)[ \t]+[A-Za-z][A-Za-z0-9_$]*([ \t]+|[<(]).*)$\n" /* Method definitions; note that constructor signatures are not */ /* matched because they are indistinguishable from method calls. */ "^[ \t]*(([A-Za-z_<>&][][?&<>.,A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",