[Git][java-team/qdox2][master] 3 commits: New upstream version 2.0.3

Markus Koschany (@apo) gitlab at salsa.debian.org
Sat Nov 12 15:44:36 GMT 2022



Markus Koschany pushed to branch master at Debian Java Maintainers / qdox2


Commits:
5939b2b7 by Markus Koschany at 2022-11-12T16:23:36+01:00
New upstream version 2.0.3
- - - - -
d25df700 by Markus Koschany at 2022-11-12T16:23:37+01:00
Update upstream source from tag 'upstream/2.0.3'

Update to upstream version '2.0.3'
with Debian dir 5be0db2affa7688af53c66d1bb35102f4a856b1f
- - - - -
6e828973 by Markus Koschany at 2022-11-12T16:24:06+01:00
Update changelog

- - - - -


10 changed files:

- .github/workflows/build.yml
- README.md
- debian/changelog
- pom.xml
- src/main/java/com/thoughtworks/qdox/library/SourceFolderLibrary.java
- src/main/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriter.java
- src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
- src/test/java/com/thoughtworks/qdox/library/SourceFolderLibraryTest.java
- src/test/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriterTest.java
- + src/test/resources/issue104/x/Test.java


Changes:

=====================================
.github/workflows/build.yml
=====================================
@@ -13,15 +13,15 @@ jobs:
         experimental: [ false ]
 
     steps:
-      - uses: actions/checkout at v2.4.0
-      - uses: actions/cache at v2.1.7
+      - uses: actions/checkout at v3.1.0
+      - uses: actions/cache at v3.0.10
         with:
           path: ~/.m2/repository
           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
           restore-keys: |
             ${{ runner.os }}-maven-
       - name: Set up JDK ${{ matrix.java }}
-        uses: actions/setup-java at v2
+        uses: actions/setup-java at v3.5.1
         with:
           java-version: ${{ matrix.java }}
           distribution: adopt


=====================================
README.md
=====================================
@@ -432,7 +432,7 @@ JavaType nType   = n.getType(); // "int";
 JavaParameter o = m.getParameters()[1];
 String oName   = o.getName(); // "objects"
 JavaType oType     = o.getType(); // "java.lang.Object";
-boolean oArray = o.getType().isArray(); // true
+boolean oArray = o.getJavaClass().isArray(); // true
 
 JavaMethod javaMethod = o.getParentMethod();
 ```


=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+qdox2 (2.0.3-1) unstable; urgency=medium
+
+  * New upstream version 2.0.3.
+
+ -- Markus Koschany <apo at debian.org>  Sat, 12 Nov 2022 16:23:55 +0100
+
 qdox2 (2.0.2-1) unstable; urgency=medium
 
   * New upstream version 2.0.2.


=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
   <name>QDox</name>
   <groupId>com.thoughtworks.qdox</groupId>
   <artifactId>qdox</artifactId>
-  <version>2.0.2</version>
+  <version>2.0.3</version>
 
   <url>https://github.com/paul-hammant/qdox</url>
   <description>
@@ -36,7 +36,7 @@
     <connection>scm:git:https://github.com/paul-hammant/qdox.git</connection>
     <developerConnection>scm:git:ssh://git@github.com/paul-hammant/qdox.git</developerConnection>
     <url>https://github.com/paul-hammant/qdox</url>
-    <tag>qdox-2.0.2</tag>
+    <tag>qdox-2.0.3</tag>
   </scm>
 
   <developers>
@@ -152,7 +152,7 @@
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-jar-plugin</artifactId>
-          <version>2.3.2</version>
+          <version>3.3.0</version>
           <configuration>
             <archive>
               <manifestEntries>
@@ -205,6 +205,20 @@
               </rules>    
             </configuration>
           </execution>
+          <execution>
+            <id>enforce-byaccj</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <requireProperty>
+                  <property>qdox.byaccj.executable</property>
+                  <message>You can't run the build as BYacc/J is not available for ${os.name} (${os.arch})!</message>
+                </requireProperty>
+              </rules>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>
@@ -364,7 +378,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.12</version>
+      <version>4.13.2</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -412,16 +426,41 @@
       </properties>
     </profile>
     <profile>
-      <id>macosx</id>
+      <id>macosx-i386</id>
+      <activation>
+        <os>
+          <family>Mac</family>
+          <arch>i386</arch>
+        </os>
+      </activation>
+      <properties>
+        <qdox.byaccj.executable>${basedir}/bootstrap/yacc.macosx</qdox.byaccj.executable>
+      </properties>
+    </profile>
+    <profile>
+     <id>macosx-powerpc</id>
       <activation>
         <os>
           <family>Mac</family>
+          <arch>powerpc</arch>
         </os>
       </activation>
       <properties>
         <qdox.byaccj.executable>${basedir}/bootstrap/yacc.macosx</qdox.byaccj.executable>
       </properties>
     </profile>
+    <profile>
+      <id>macosx-aarch64</id>
+      <activation>
+        <os>
+          <family>Mac</family>
+          <arch>aarch64</arch>
+        </os>
+      </activation>
+      <properties>
+        <qdox.byaccj.executable>${basedir}/bootstrap/yacc.macosx.aarch64</qdox.byaccj.executable>
+      </properties>
+    </profile>
     <profile>
       <id>windows</id>
       <activation>


=====================================
src/main/java/com/thoughtworks/qdox/library/SourceFolderLibrary.java
=====================================
@@ -25,7 +25,6 @@ import java.io.FileReader;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -106,25 +105,11 @@ public class SourceFolderLibrary
     protected JavaClass resolveJavaClass( String className )
     {
         JavaClass result = super.resolveJavaClass( className );
-        for ( File sourceFolder : sourceFolders )
+        String mainClassName = className.split( "\\$" )[0];
+        File sourceFile = getSourceFile( mainClassName );
+        if ( sourceFile != null )
         {
-            String mainClassName = className.split( "\\$" )[0];
-            File classFile = new File( sourceFolder, mainClassName.replace( '.', File.separatorChar ) + ".java" );
-            if ( classFile.isFile() )
-            {
-                try
-                {
-                    JavaSource source = parse( new FileReader( classFile ), classFile.toURI().toURL() ).getSource();
-                    result = source.getClassByName( className );
-                    break;
-                }
-                catch ( FileNotFoundException e )
-                {
-                }
-                catch ( MalformedURLException e )
-                {
-                }
-            }
+            result = getClassFromSourceFile( sourceFile, className );
         }
         return result;
     }
@@ -138,15 +123,48 @@ public class SourceFolderLibrary
     protected boolean containsClassReference( String className )
     {
         boolean result = super.containsClassReference( className );
-        for ( Iterator<File> iterator = sourceFolders.iterator(); !result && iterator.hasNext(); )
+        if ( !result )
         {
-            File sourceFolder = (File) iterator.next();
             String mainClassName = className.split( "\\$" )[0];
-            File classFile = new File( sourceFolder, mainClassName.replace( '.', File.separatorChar ) + ".java" );
-            
-            result = ( classFile.exists() && classFile.isFile() );
+            File sourceFile = getSourceFile( mainClassName );
+            if ( sourceFile != null )
+            {
+                if ( mainClassName.equals( className ) ) {
+                    result = true;
+                } else {
+                    result = getClassFromSourceFile( sourceFile, className ) != null;
+                }
+            }
         }
         return result;
     }
-    
+
+    private File getSourceFile( String mainClassName )
+    {
+        for ( File sourceFolder : sourceFolders )
+        {
+            File classFile = new File( sourceFolder, mainClassName.replace( '.', File.separatorChar ) + ".java" );
+            if ( classFile.isFile() )
+            {
+                return classFile;
+            }
+        }
+        return null;
+    }
+
+    private JavaClass getClassFromSourceFile( File sourceFile, String className )
+    {
+        try
+        {
+            JavaSource source = parse( new FileReader( sourceFile ), sourceFile.toURI().toURL() ).getSource();
+            return source.getClassByName( className );
+        }
+        catch ( FileNotFoundException e )
+        {
+        }
+        catch ( MalformedURLException e )
+        {
+        }
+        return null;
+    }
 }


=====================================
src/main/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriter.java
=====================================
@@ -357,7 +357,9 @@ public class DefaultModelWriter
     {
         for ( String modifier : modifiers )
         {
-            if ( !modifier.startsWith( "p" ) )
+            // interface is included as a modifier
+            // https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/reflect/Modifier.html#toString(int)
+            if ( !modifier.startsWith( "p" ) && !"interface".equals( modifier ) )
             {
                 buffer.write( modifier );
                 buffer.write( ' ' );


=====================================
src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
=====================================
@@ -623,6 +623,31 @@ public class JavaProjectBuilderTest extends TestCase
         assertNull("Shouldn't be able to get private methods", betterList.getMethodBySignature("myown", null, true));
     }
 
+    public void testMethodsWithNonQualifiedTypesFromJavaLangCanBeRetrievedFromSourceFolderLibrary() {
+        builder.addSourceFolder( new File( "src/test/resources/issue104") );
+        JavaClass testClass = builder.getClassByName("x.Test");
+        assertNull(testClass.getMethodBySignature("test", null));
+        JavaType argumentType = builder.getClassByName("java.lang.Integer");
+        assertNotNull(testClass.getMethodBySignature("test", Collections.singletonList( argumentType )));
+    }
+
+    public void testMethodsWithNonQualifiedTypesFromJavaLangCanBeRetrievedFromSourceLibrary() {
+        String testSource = ""
+                        + "package x;"
+                        + "/**"
+                        + " * @foo bar"
+                        + " */"
+                        + "class Test {"
+                        + "  public void test(Integer value) {}"
+                        + "}";
+        builder.addSource(new StringReader(testSource));
+
+        JavaClass testClass = builder.getClassByName("x.Test");
+        assertNull(testClass.getMethodBySignature("test", null));
+        JavaType argumentType = builder.getClassByName("java.lang.Integer");
+        assertNotNull(testClass.getMethodBySignature("test", Collections.singletonList( argumentType )));
+    }
+
     public void testTagLineNumbersAndSourceInTags() {
         String jallaSource = ""
                 + "package x;\n"


=====================================
src/test/java/com/thoughtworks/qdox/library/SourceFolderLibraryTest.java
=====================================
@@ -1,14 +1,9 @@
 package com.thoughtworks.qdox.library;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
 import java.io.File;
 import java.io.StringReader;
 import java.util.Iterator;
 
-import org.junit.Test;
-
 import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.JavaModule;
 import com.thoughtworks.qdox.model.JavaModuleDescriptor;
@@ -17,6 +12,12 @@ import com.thoughtworks.qdox.model.JavaModuleDescriptor.JavaOpens;
 import com.thoughtworks.qdox.model.JavaModuleDescriptor.JavaProvides;
 import com.thoughtworks.qdox.model.JavaModuleDescriptor.JavaRequires;
 import com.thoughtworks.qdox.model.JavaModuleDescriptor.JavaUses;
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 public class SourceFolderLibraryTest
 {
@@ -108,5 +109,13 @@ public class SourceFolderLibraryTest
         cls = classIter.next();
         assertEquals( "Z3.Z4", cls.getFullyQualifiedName() );
     }
-    
+
+    @Test
+    public void testHasClassReference() {
+        library.addSourceFolder( new File("src/test/resources") );
+        assertFalse( library.hasClassReference( "Integer" ) );
+        assertTrue( library.hasClassReference( "com.thoughtworks.qdox.testdata.DefaultCtor" ) );
+        // the following (non-existing) FQCN is called e.g. from TypeResolver
+        assertFalse( library.hasClassReference( "com.thoughtworks.qdox.testdata.DefaultCtor$Integer" ) );
+    }
 }


=====================================
src/test/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriterTest.java
=====================================
@@ -1,5 +1,7 @@
 package com.thoughtworks.qdox.writer.impl;
 
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -13,6 +15,8 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.thoughtworks.qdox.library.ClassLibrary;
+import com.thoughtworks.qdox.library.SortedClassLibraryBuilder;
 import com.thoughtworks.qdox.model.DocletTag;
 import com.thoughtworks.qdox.model.JavaAnnotatedElement;
 import com.thoughtworks.qdox.model.JavaAnnotation;
@@ -542,4 +546,15 @@ public class DefaultModelWriterTest {
         modelWriter.writeModuleUses( uses );
         assertEquals( "uses V.W;\n", modelWriter.toString() );
     }
+    
+    @Test
+    public void interfaceModifier()
+    {
+        ClassLibrary classLibrary = new SortedClassLibraryBuilder()
+                        .appendDefaultClassLoaders()
+                        .getClassLibrary();
+        
+        JavaClass clazz = classLibrary.getJavaClass( "java.util.Set" );
+        assertThat( clazz.getCodeBlock(), startsWith( "public abstract interface Set" ) );
+    }
 }


=====================================
src/test/resources/issue104/x/Test.java
=====================================
@@ -0,0 +1,5 @@
+package x;
+
+class Test {
+    public void test(Integer value) {}
+};
\ No newline at end of file



View it on GitLab: https://salsa.debian.org/java-team/qdox2/-/compare/ad20e50646d76bc1ebc89394fc37bd06a3d70808...6e828973ded69d253afbeeb2bef198e09e081717

-- 
View it on GitLab: https://salsa.debian.org/java-team/qdox2/-/compare/ad20e50646d76bc1ebc89394fc37bd06a3d70808...6e828973ded69d253afbeeb2bef198e09e081717
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221112/dc3a781c/attachment.htm>


More information about the pkg-java-commits mailing list