From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id C9B402BF76 for ; Tue, 6 Feb 2024 11:25:05 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707215105; b=Tv4B0cO+sp34xxb1IHob4otC+nTuJKcFqEsuEAc/8ym8ViCXwKEyyDXZ9kLZLeAlDRoeaKuWkJ 9hPt8YXNrUIsH/hoks3VI2Op1So++busXHbb2XIxKhAZkcDH/LhFXVEhCv2lhWw3S55Zl4Mybg +WDXFfSHpwofKQgA4oa9KZTe18GinRJnHlfORcbml+PJiVNGGXQfAvIrIYDrZpirCV2TDOikzf gHRdIa7DfsWTR2iSZqKnVS18GYTMcNhvOsoyMoIRRcsxQ0QBpbV9frjTRxzaAjeufe/BXgN9dq JDhd9Ny9Np2z/u0GzLUUBM8ZOo6DsqdcEjxyh0FQVHNjUA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mx1.icm.edu.pl) smtp.remote-ip=213.135.59.49; dmarc=none header.from=meep.pl; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1707215105; bh=xlkjs/+Pz+k2LGOmZo3OYdVnjR1DYD6HDuPga/AsxAk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=WfnsyVFaLVSFoiz1R6CiLE1S4XddqSc0AYnrCZrx1VdzeL4owyHLm5J9rKKqqxpWqjASoMP3C5 7yqQO3LBPyenNMSKzckN+cDOBDOon1ml+JgTlxAscmHvPNEwLRxwpqPhSwOYf5L9zasCddqKPP nKTaV0jPnmejPeyvfnSp6cPxkMAYwajN8EV3LDVzugKSkPdPWR3/50Fm5o71JDxSTudFKZCex3 uWj59obKEiJeArOLCQax2fcs8raFeSY8Z7CRjUIc1DpMnluwAF4yCYFqsIntfW0mfDVMMh5HDg UEjwZk8ZxwkgiE8Jd8Y3PRieQKETYoqoSRAZIsUxV2wYdw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=tOTCP0MPxPds6C3/310nWRbhD6exf+qzLT3cY26nMCU=; b=VVBVfxcY9hWWeBr1h7MXPuKjGM qSLwsEdHRHE0af9wMrfxMi21yzyoQpMfrVuwCoqKiHUVqPOglNwbNHeTfbeaTN7K141d4tjw29iCd Q6dHM0JULh9oId8kyBClVoFwlFsoEi6tOhnfb1WfF8UWtcfbOp2rhhLxe7bCCeyr826lDBA+G4OeE rn2TGJ5ByzPmH7wPvnIMIdoTgKiYhBWjpZPIyZJOo5uepV+snQkL06bT7qKpXvMuDQWzYDtZPtJNv qJt7dsdXtTSTenCFQ4Iy8if24ssPN5lA+mEfrZFz8XudRh/UTR9UHnDI1CiV5AoFXVZjhptM+boRU 2YOTzQ1g==; Received: by zero.zsh.org with local id 1rXIdU-0001Y7-FS; Tue, 06 Feb 2024 10:25:04 +0000 Authentication-Results: zsh.org; iprev=pass (mx1.icm.edu.pl) smtp.remote-ip=213.135.59.49; dmarc=none header.from=meep.pl; arc=none Received: from mx1.icm.edu.pl ([213.135.59.49]:60012) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rXIcY-0000ol-69; Tue, 06 Feb 2024 10:24:07 +0000 X-Virus-Scanned: amavisd-new at amavis-3.icm.edu.pl Received: from smtp.icm.edu.pl (mail.icm.edu.pl [213.135.59.43]) by mx1.icm.edu.pl (Postfix) with ESMTP for ; Tue, 6 Feb 2024 11:24:02 +0100 (CET) Received: from Amber.meep.pl (89-78-88-113.dynamic.chello.pl [89.78.88.113]) by smtp.icm.edu.pl (Postfix) with ESMTPSA id D73751FD6F for ; Tue, 6 Feb 2024 11:24:01 +0100 (CET) Received: from mike by Amber.meep.pl with local (Exim 4.97) (envelope-from ) id 1rXIcR-000000000RI-0pM3 for zsh-users@zsh.org; Tue, 06 Feb 2024 11:23:59 +0100 Date: Tue, 6 Feb 2024 11:23:59 +0100 From: Michal Politowski To: zsh-users@zsh.org Subject: Re: Java completion for Java files Message-ID: Mail-Followup-To: zsh-users@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Seq: 29645 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Dnia Mon, 5 Feb 2024 21:47:48 -0500, Henri Tremblay napisa=C5=82(a): > Yes. > Let's say you have a file in a directory: > "src/main/java/org/zsh/Main.java". The class is named Main and is in the > package org.zsh in this case. > If you compile it with "javac src/main/java/org/zsh/Main.java" it will > generate a file named "src/main/java/org/zsh/Main.class". >=20 > So, if you execute it the old way, you would do "java -cp src/main/java > org.zsh.Main" which means "Please execute the class with a main() method > that is called Main and found in the package org.zsh. The classpath where > this class can be found is "src/main". >=20 > If you execute it the new way, you don't need to compile with javac. So y= ou > only have "src/main/java/org/zsh/Main.java". > And you will execute by doing "java src/main/java/org/zsh/Main.java" and > that's it. >=20 > Bottom line, indeed, the ".java" at the end tells that it's a java source > file and not a compile class found in the classpath that you want to > execute. Not exactly. You can have a class named java on the classpath. The precise behaviour as specified here https://openjdk.org/jeps/330#Descri= ption (since Java 11) seems to be: if the first non-option argument is - a name of an existing file with .java extension, or - a name of an existing file and the --source option is given then compile/run the source. > On Mon, 5 Feb 2024 at 15:44, Bart Schaefer > wrote: >=20 > > On Mon, Feb 5, 2024 at 10:04=E2=80=AFAM Henri Tremblay > > wrote: > > > > > > Java now supports (since Java 10 I think) command lines like > > > > > > java Math.java > > > > > > It will then just compile and launch that java file. But zsh won't > > autocomplete for that. It only wants a jar, class file or whatever. > > > > The issue is here in the _arguments setup for _java: > > > > '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}= ' \ > > '*::args:=3D _normal' \ > > && return 0 > > > > The (-) says that the first word after "java" must either be an option > > (start with "-") or must be a class name. The completion stops there > > unless working on the next word. > > > > How does "java" itself distinguish between a class name and a file > > name? Just whether the string ends in ".java"? > > --=20 Micha=C5=82 Politowski Talking has been known to lead to communication if practiced carelessly.