├── .gitignore ├── .hgignore ├── .travis.yml ├── legal └── copyright.txt └── src ├── main ├── resources │ └── com │ │ └── sun │ │ └── tdk │ │ └── signaturetest │ │ ├── model │ │ └── i18n.properties │ │ ├── merge │ │ └── i18n.properties │ │ ├── classpath │ │ └── i18n.properties │ │ ├── sigfile │ │ └── i18n.properties │ │ ├── util │ │ └── i18n.properties │ │ ├── loaders │ │ └── i18n.properties │ │ ├── core │ │ └── i18n.properties │ │ └── errors │ │ └── i18n.properties └── java │ ├── com │ └── sun │ │ └── tdk │ │ ├── signaturetest │ │ ├── plugin │ │ │ ├── Context.java │ │ │ ├── Transformer.java │ │ │ ├── Filter.java │ │ │ ├── ReaderAdapter.java │ │ │ ├── WriterAdapter.java │ │ │ ├── Plugin.java │ │ │ ├── FormatAdapter.java │ │ │ └── PluginAPI.java │ │ ├── core │ │ │ ├── ClassDescriptionLoader.java │ │ │ ├── Log.java │ │ │ ├── JDKExclude.java │ │ │ ├── ExcludeException.java │ │ │ ├── PrimitiveTypes.java │ │ │ ├── Exclude.java │ │ │ ├── ClassHierarchy.java │ │ │ └── PackageGroup.java │ │ ├── sigfile │ │ │ ├── F41Reader.java │ │ │ ├── Parser.java │ │ │ ├── Format.java │ │ │ ├── F21Format.java │ │ │ ├── Writer.java │ │ │ ├── F31Reader.java │ │ │ ├── F31Format.java │ │ │ ├── F40Reader.java │ │ │ ├── Reader.java │ │ │ ├── F41Format.java │ │ │ ├── F40Format.java │ │ │ ├── F41Writer.java │ │ │ ├── FeaturesHolder.java │ │ │ └── F41Parser.java │ │ ├── util │ │ │ ├── CommandLineParserException.java │ │ │ ├── LRUCache.java │ │ │ ├── SwissKnife.java │ │ │ ├── OptionInfo.java │ │ │ └── LogFormatter.java │ │ ├── ant │ │ │ ├── ASuperBase.java │ │ │ └── ABase.java │ │ ├── remote │ │ │ └── RemoteLoadManager.java │ │ ├── errors │ │ │ ├── Chain.java │ │ │ └── BCUtils.java │ │ ├── Version.java │ │ ├── loaders │ │ │ ├── LoadingHints.java │ │ │ └── VirtualClassDescriptionLoader.java │ │ ├── classpath │ │ │ ├── Classpath.java │ │ │ ├── ClasspathEntry.java │ │ │ ├── Release.java │ │ │ └── JarFileEntry.java │ │ ├── merge │ │ │ └── MergedSigFile.java │ │ ├── model │ │ │ ├── SuperClass.java │ │ │ ├── InnerDescr.java │ │ │ ├── SuperInterface.java │ │ │ ├── PackageDescr.java │ │ │ └── MemberCollection.java │ │ └── Result.java │ │ ├── apicheck │ │ ├── ApiCheck.java │ │ ├── ant │ │ │ └── ACheck.java │ │ └── Main.java │ │ ├── apicover │ │ ├── markup │ │ │ └── Adapter.java │ │ └── i18n.properties │ │ └── exclude │ │ └── ExcludeList.java │ └── org │ └── netbeans │ └── apitest │ ├── ListCtSym.java │ └── SigtestCompare.java └── test ├── java ├── org │ └── netbeans │ │ └── apitest │ │ ├── StrictCheckSigtestTest.java │ │ ├── APIWithPropertyTest.java │ │ ├── APIWithReleaseTest.java │ │ └── VersionCheckSigtestTest.java └── com │ └── sun │ └── tdk │ └── signaturetest │ └── classpath │ └── ReleaseTest.java └── resources └── org └── netbeans └── apitest ├── PropertySupport.template └── build.xml /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | nb-configuration.xml 3 | 4 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | target 2 | ^.*\.orig 3 | .*/.svn/.* 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | - openjdk11 5 | sudo: required 6 | script: 7 | - mvn install 8 | os: 9 | - linux 10 | env: 11 | - TEST_SUITE=all 12 | -------------------------------------------------------------------------------- /legal/copyright.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 2 | DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 | 4 | This code is free software; you can redistribute it and/or modify it 5 | under the terms of the GNU General Public License version 2 only, as 6 | published by the Free Software Foundation. Oracle designates this 7 | particular file as subject to the "Classpath" exception as provided 8 | by Oracle in the LICENSE file that accompanied this code. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | version 2 for more details (a copy is included in the LICENSE file that 14 | accompanied this code). 15 | 16 | You should have received a copy of the GNU General Public License version 17 | 2 along with this work; if not, write to the Free Software Foundation, 18 | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 | or visit www.oracle.com if you need additional information or have any 22 | questions. 23 | -------------------------------------------------------------------------------- /src/main/resources/com/sun/tdk/signaturetest/model/i18n.properties: -------------------------------------------------------------------------------- 1 | # 2 | # $Id: i18n.properties 4504 2008-03-13 16:12:22Z sg215604 $ 3 | # 4 | # 5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 | # 8 | # This code is free software; you can redistribute it and/or modify it 9 | # under the terms of the GNU General Public License version 2 only, as 10 | # published by the Free Software Foundation. Sun designates this 11 | # particular file as subject to the "Classpath" exception as provided 12 | # by Sun in the LICENSE file that accompanied this code. 13 | # 14 | # This code is distributed in the hope that it will be useful, but WITHOUT 15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | # version 2 for more details (a copy is included in the LICENSE file that 18 | # accompanied this code). 19 | # 20 | # You should have received a copy of the GNU General Public License version 21 | # 2 along with this work; if not, write to the Free Software Foundation, 22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 25 | # CA 95054 USA or visit www.sun.com if you need additional information or 26 | # have any questions. 27 | # 28 | 29 | ClassDescription.error.declaredtwice=Type parameter ''{0}'' declared in ''{1}'' and in ''{2}'' 30 | ClassDescription.error.undefined=Type parameter undefined {0} 31 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/plugin/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.plugin; 29 | 30 | import com.sun.tdk.signaturetest.core.Log; 31 | 32 | public interface Context { 33 | 34 | Log getLog(); 35 | boolean isDebugMode(); 36 | boolean isTestMode(); 37 | boolean isSetup(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/plugin/Transformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.plugin; 29 | 30 | import com.sun.tdk.signaturetest.model.ClassDescription; 31 | 32 | /** 33 | * @author Roman Makarchuk 34 | */ 35 | public interface Transformer { 36 | ClassDescription transform(ClassDescription cls) throws ClassNotFoundException; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/plugin/Filter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.plugin; 29 | 30 | import com.sun.tdk.signaturetest.model.ClassDescription; 31 | 32 | /** 33 | * @author Roman Makarchuk 34 | */ 35 | public interface Filter { 36 | 37 | // returns false if the cls should be skipped 38 | boolean accept(ClassDescription cls); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/core/ClassDescriptionLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: ClassDescriptionLoader.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.core; 29 | 30 | import com.sun.tdk.signaturetest.model.ClassDescription; 31 | 32 | public interface ClassDescriptionLoader { 33 | 34 | ClassDescription load(String className) throws ClassNotFoundException; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/sigfile/F41Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: F41Reader.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.sigfile; 29 | 30 | public class F41Reader extends F40Reader { 31 | 32 | public F41Reader(Format format) { 33 | super(format); 34 | } 35 | 36 | protected Parser getParser() { 37 | return new F41Parser(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/core/Log.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: Log.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.core; 29 | 30 | import java.util.logging.Logger; 31 | 32 | /* 33 | * @author Mikhail Ershov 34 | * @author Roman Makarchuk 35 | */ 36 | public interface Log { 37 | void storeError(String s, Logger utilLogger); 38 | void storeWarning(String s, Logger utilLogger); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/plugin/ReaderAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.plugin; 29 | 30 | import com.sun.tdk.signaturetest.sigfile.F41Reader; 31 | import com.sun.tdk.signaturetest.sigfile.Format; 32 | 33 | /** 34 | * @author Mikhail Ershov 35 | */ 36 | public class ReaderAdapter extends F41Reader { 37 | public ReaderAdapter(Format format) { 38 | super(format); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/plugin/WriterAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.plugin; 29 | 30 | import com.sun.tdk.signaturetest.sigfile.F41Writer; 31 | import com.sun.tdk.signaturetest.sigfile.Format; 32 | 33 | /** 34 | * @author Mikhail Ershov 35 | */ 36 | public class WriterAdapter extends F41Writer { 37 | public WriterAdapter(Format f) { 38 | super(); 39 | format = f; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/sigfile/Parser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: Parser.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.sigfile; 29 | 30 | import com.sun.tdk.signaturetest.model.ClassDescription; 31 | 32 | import java.util.List; 33 | 34 | /** 35 | * @author Roman Makarchuk 36 | */ 37 | public interface Parser { 38 | public ClassDescription parseClassDescription(String classDefinition, List /*String*/ members); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/plugin/Plugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.plugin; 29 | 30 | /** 31 | * @author Roman Makarchuk 32 | */ 33 | public interface Plugin { 34 | // the method is called right after SigTest parsed command line parameters and finished own initialization 35 | void init(PluginAPI api); 36 | 37 | // the method is called when Test completed to free all resources allocated by the plugin 38 | void release(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/util/CommandLineParserException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: CommandLineParserException.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.util; 29 | 30 | public class CommandLineParserException extends Exception{ 31 | 32 | public CommandLineParserException(String message) { 33 | super(message); 34 | } 35 | 36 | public CommandLineParserException(String message, Throwable cause) { 37 | super(message, cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/ant/ASuperBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: SignatureTest.java 4549 2008-03-24 08:03:34Z me155718 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.ant; 29 | 30 | import org.apache.tools.ant.Task; 31 | 32 | public class ASuperBase extends Task { 33 | protected boolean failOnError = false; 34 | protected boolean negative = false; 35 | 36 | public void setFailonerror(boolean fail) { 37 | failOnError = fail; 38 | } 39 | 40 | public void setNegative(boolean d) { 41 | negative = d; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/apicheck/ApiCheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: SignatureTest.java 4549 2008-03-24 08:03:34Z me155718 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | 29 | package com.sun.tdk.apicheck; 30 | 31 | import com.sun.tdk.signaturetest.SignatureTest; 32 | 33 | /* 34 | * @author Mikhail Ershov 35 | */ 36 | public class ApiCheck extends SignatureTest { 37 | 38 | protected boolean isAPICheckMode() { 39 | return true; 40 | } 41 | 42 | public boolean exit() { 43 | return super.exit(); 44 | } 45 | 46 | protected String getComponentName() { 47 | return "ApiCheck"; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/resources/com/sun/tdk/signaturetest/merge/i18n.properties: -------------------------------------------------------------------------------- 1 | # 2 | # $Id$ 3 | # 4 | # 5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 | # 8 | # This code is free software; you can redistribute it and/or modify it 9 | # under the terms of the GNU General Public License version 2 only, as 10 | # published by the Free Software Foundation. Sun designates this 11 | # particular file as subject to the "Classpath" exception as provided 12 | # by Sun in the LICENSE file that accompanied this code. 13 | # 14 | # This code is distributed in the hope that it will be useful, but WITHOUT 15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | # version 2 for more details (a copy is included in the LICENSE file that 18 | # accompanied this code). 19 | # 20 | # You should have received a copy of the GNU General Public License version 21 | # 2 along with this work; if not, write to the Free Software Foundation, 22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 25 | # CA 95054 USA or visit www.sun.com if you need additional information or 26 | # have any questions. 27 | # 28 | 29 | 30 | 31 | Merger.error.packageconflict= : <{0}> name of class conflict with package 32 | Merger.error.modifierconfict= : <{0}> modifier conflict 33 | Merger.error.classwithinterface= : trying to merge interface with class! 34 | Merger.error.typeconflict= : type conflict <{0}> and <{1}> 35 | Merger.error.throwconflict= : throws conflict <{0}> and <{1}> 36 | Merger.error.differentvalues= : different values <{0}> and <{1}> 37 | Merger.error.superclassesnotrelated= : superclasses not related <{0}> and <{1}> 38 | 39 | 40 | Merger.error=Error -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/core/JDKExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id:$ 3 | * 4 | * Copyright 2021 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.core; 29 | 30 | /** 31 | * JDKExclude represents the JDK classes to be excluded from signature testing. 32 | * 33 | * @author Scott Marlow 34 | */ 35 | public interface JDKExclude { 36 | 37 | /** 38 | * Check for JDK classes that should be excluded from signature testing. 39 | * @param name is class name (with typical dot separators) to check. 40 | * @return true if the class should be excluded from signature testing. 41 | */ 42 | boolean isJdkClass(String name); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/sigfile/Format.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: Format.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.sigfile; 29 | 30 | /** 31 | * @author Roman Makarchuk 32 | */ 33 | public abstract class Format extends FeaturesHolder { 34 | 35 | public static final String VERSION = "#Version "; 36 | 37 | public abstract String getVersion(); 38 | 39 | public abstract Reader getReader(); 40 | 41 | public abstract Writer getWriter(); 42 | 43 | 44 | public boolean isApplicable(String format) { 45 | return getVersion().equals(format); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/resources/com/sun/tdk/signaturetest/classpath/i18n.properties: -------------------------------------------------------------------------------- 1 | # 2 | # $Id: i18n.properties 4504 2008-03-13 16:12:22Z sg215604 $ 3 | # 4 | # 5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 | # 8 | # This code is free software; you can redistribute it and/or modify it 9 | # under the terms of the GNU General Public License version 2 only, as 10 | # published by the Free Software Foundation. Sun designates this 11 | # particular file as subject to the "Classpath" exception as provided 12 | # by Sun in the LICENSE file that accompanied this code. 13 | # 14 | # This code is distributed in the hope that it will be useful, but WITHOUT 15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | # version 2 for more details (a copy is included in the LICENSE file that 18 | # accompanied this code). 19 | # 20 | # You should have received a copy of the GNU General Public License version 21 | # 2 along with this work; if not, write to the Free Software Foundation, 22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 25 | # CA 95054 USA or visit www.sun.com if you need additional information or 26 | # have any questions. 27 | # 28 | 29 | 30 | ClasspathImpl.error.notdefinepathsep=Can''t define path separator 31 | ClasspathImpl.error.ignoring=Warning: incorrect classpath parameter: {0} ({1}). This directory or jar file will be ignored! 32 | ClasspathImpl.error.duplicate_entry_found=Warning: {0} specified twice in the classpath. 33 | 34 | DirectoryEntry.error.invdir={0} isn''t directory. 35 | #DirectoryEntry.error.secpack=The Security constraints does not allow to track {0} 36 | #DirectoryEntry.error.nonclass=The current class not exist. 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/signaturetest/sigfile/F21Format.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: F21Format.java 4504 2008-03-13 16:12:22Z sg215604 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.signaturetest.sigfile; 29 | 30 | /** 31 | * @author Roman Makarchuk 32 | */ 33 | public class F21Format extends Format { 34 | 35 | { 36 | addSupportedFeature(FeaturesHolder.ConstInfo); 37 | } 38 | 39 | public String getVersion() { 40 | return "#Signature file v2.1"; 41 | } 42 | 43 | public Reader getReader() { 44 | return new F21Reader(this); 45 | } 46 | 47 | public Writer getWriter() { 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/resources/com/sun/tdk/signaturetest/sigfile/i18n.properties: -------------------------------------------------------------------------------- 1 | # 2 | # $Id$ 3 | # 4 | # 5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 | # 8 | # This code is free software; you can redistribute it and/or modify it 9 | # under the terms of the GNU General Public License version 2 only, as 10 | # published by the Free Software Foundation. Sun designates this 11 | # particular file as subject to the "Classpath" exception as provided 12 | # by Sun in the LICENSE file that accompanied this code. 13 | # 14 | # This code is distributed in the hope that it will be useful, but WITHOUT 15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 | # version 2 for more details (a copy is included in the LICENSE file that 18 | # accompanied this code). 19 | # 20 | # You should have received a copy of the GNU General Public License version 21 | # 2 along with this work; if not, write to the Free Software Foundation, 22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 25 | # CA 95054 USA or visit www.sun.com if you need additional information or 26 | # have any questions. 27 | # 28 | 29 | 30 | MultipleFileReader.error.sigfile.invalid=Invalid signature file: {0} 31 | #MultipleFileReader.error.sigreader.missing=Can''t find reader for {0} or file doesn''t exist 32 | 33 | MultipleFileReader.error.sigfile.prob=Problem with signature file 34 | MultipleFileReader.error.sigfile.sec=Security constraints does not allow to read from signature file 35 | 36 | MultipleFileReader.error.url.threwerror={0} throw {1} 37 | 38 | MultipleFileReader.error.cannt_merge_old_files=Old signature files can't be merged automatically: 39 | 40 | AnnotationParser.error.bad_annotation_descr=Bad annotation item {0} -------------------------------------------------------------------------------- /src/main/java/com/sun/tdk/apicheck/ant/ACheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: SignatureTest.java 4549 2008-03-24 08:03:34Z me155718 $ 3 | * 4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. Sun designates this 10 | * particular file as subject to the "Classpath" exception as provided 11 | * by Sun in the LICENSE file that accompanied this code. 12 | * 13 | * This code is distributed in the hope that it will be useful, but WITHOUT 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 | * version 2 for more details (a copy is included in the LICENSE file that 17 | * accompanied this code). 18 | * 19 | * You should have received a copy of the GNU General Public License version 20 | * 2 along with this work; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 | * 23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 | * CA 95054 USA or visit www.sun.com if you need additional information or 25 | * have any questions. 26 | */ 27 | 28 | package com.sun.tdk.apicheck.ant; 29 | 30 | import com.sun.tdk.apicheck.ApiCheck; 31 | import com.sun.tdk.signaturetest.SignatureTest; 32 | import com.sun.tdk.signaturetest.ant.ATest; 33 | 34 | 35 | /** 36 | *
37 | * Ant wrapper for APICheck
38 | * All parameters are similar to ATest
39 | *
40 | * @see com.sun.tdk.signaturetest.ant.ATest
41 | * @author Mikhail Ershov
42 | */
43 | public class ACheck extends ATest {
44 |
45 | protected SignatureTest testFactory() {
46 | return new ApiCheck();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/Writer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: Writer.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import com.sun.tdk.signaturetest.model.ClassDescription;
31 |
32 | import java.io.PrintWriter;
33 |
34 | /**
35 | * @author Roman Makarchuk
36 | */
37 | public interface Writer {
38 |
39 | public void init(PrintWriter out);
40 |
41 | void setApiVersion(String apiVersion);
42 | public void addFeature(Format.Feature feature);
43 |
44 | public void writeHeader();
45 | public void write(ClassDescription classDescription);
46 |
47 | public void close();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F31Reader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F31Reader.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import java.util.List;
31 |
32 | class F31Reader extends SignatureClassLoader implements Reader {
33 |
34 |
35 | F31Reader(Format format) {
36 | super(format);
37 | }
38 |
39 | protected String convertClassDescr(String descr) {
40 | return descr;
41 | }
42 |
43 | protected List convertClassDefinitions(List definitions) {
44 | return definitions;
45 | }
46 |
47 | protected Parser getParser() {
48 | return new F31Parser();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F31Format.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F31Format.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | /**
31 | * @author Roman Makarchuk
32 | */
33 | class F31Format extends Format {
34 |
35 | {
36 | addSupportedFeature(FeaturesHolder.TigerInfo);
37 | addSupportedFeature(FeaturesHolder.ConstInfo);
38 | }
39 |
40 | public String getVersion() {
41 | return "#Signature file v3.1";
42 | }
43 |
44 | public Reader getReader() {
45 | return new F31Reader(this);
46 | }
47 |
48 | public Writer getWriter() {
49 | return null;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/util/LRUCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: LRUCache.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.util;
29 |
30 | import java.util.Map;
31 |
32 | /**
33 | * @author Roman Makarchuk
34 | */
35 | public class LRUCache extends java.util.LinkedHashMap {
36 |
37 | private static float LOAD_FACTOR = 0.75f;
38 | protected int maxSize;
39 |
40 | public LRUCache(int maxsize) {
41 | super((int) (maxsize / LOAD_FACTOR + 1), LOAD_FACTOR, true);
42 | this.maxSize = maxsize;
43 | }
44 |
45 | protected boolean removeEldestEntry(Map.Entry eldest) {
46 | return size() > maxSize;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F40Reader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F40Reader.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import java.util.List;
31 |
32 | public class F40Reader extends SignatureClassLoader implements Reader {
33 |
34 | public F40Reader(Format format) {
35 | super(format);
36 | }
37 |
38 | protected String convertClassDescr(String descr) {
39 | return descr;
40 | }
41 |
42 | protected List convertClassDefinitions(List definitions) {
43 | return definitions;
44 | }
45 |
46 | protected Parser getParser() {
47 | return new F40Parser();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/Reader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: Reader.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import com.sun.tdk.signaturetest.model.ClassDescription;
31 |
32 | import java.io.IOException;
33 | import java.net.URL;
34 | import java.util.Set;
35 |
36 | /**
37 | * @author Mikhail Ershov
38 | */
39 | public interface Reader {
40 |
41 | boolean hasFeature(Format.Feature feature);
42 |
43 | Set getAllSupportedFeatures();
44 |
45 | boolean readSignatureFile(URL fileURL) throws IOException;
46 |
47 | ClassDescription readNextClass() throws IOException;
48 |
49 | void close() throws IOException;
50 |
51 | String getApiVersion();
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/apicheck/Main.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: SignatureTest.java 4549 2008-03-24 08:03:34Z me155718 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 |
29 | package com.sun.tdk.apicheck;
30 |
31 | import java.io.PrintWriter;
32 |
33 | /*
34 | * @author Mikhail Ershov
35 | */
36 | public class Main {
37 |
38 | public static void main(String[] args) {
39 | try {
40 | Class.forName("com.sun.tdk.signaturetest.SignatureTest");
41 | } catch (ClassNotFoundException e) {
42 | System.out.println("ERROR - Neither sigtest.jar nor sigtestdev.jar found in classpath");
43 | System.exit(98);
44 | }
45 |
46 | ApiCheck t = new ApiCheck();
47 | t.run(args, new PrintWriter(System.err, true), null);
48 | t.exit();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/core/ExcludeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: ExcludeException.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.core;
29 |
30 |
31 | /**
32 | * The ExcludeException is thrown by Exclude implementation
33 | * to exclude API item and describe the reason as the message of exception.
34 | * The getMessage() method is used to get message by SignatureTest, this message
35 | * is printed in verbose mode.
36 | *
37 | * @author Leonid Mesnik
38 | */
39 | public class ExcludeException extends Exception {
40 |
41 | /**
42 | * Creates the Exception with specified message.
43 | * @param message the reason of exclusion
44 | */
45 | public ExcludeException(String message) {
46 | super(message);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/util/SwissKnife.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: SwissKnife.java 4516 2008-03-17 18:48:27Z eg216457 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.util;
29 |
30 | public class SwissKnife {
31 |
32 | /**
33 | * Determines whether the object x is equal to
34 | * object y. If (x == null) and
35 | * (y == null) the result is true.
36 | *
37 | * @param x - first comparable object, may by null
38 | * @param y - second comparable object, may by null
39 | * @return true if x equal to y
40 | */
41 | public static boolean equals(Object x, Object y) {
42 | if (x == null)
43 | return y == null;
44 |
45 | return x.equals(y);
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F41Format.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F41Format.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | public class F41Format extends F40Format {
31 |
32 | public F41Format() {
33 | addSupportedFeature(FeaturesHolder.NonStaticConstants);
34 | addSupportedFeature(FeaturesHolder.XHiders);
35 | addSupportedFeature(FeaturesHolder.OuterClasses);
36 | }
37 |
38 | public String getVersion() {
39 | return "#Signature file v4.1";
40 | }
41 |
42 | public Reader getReader() {
43 | return new F41Reader(this);
44 | }
45 |
46 | public Writer getWriter() {
47 | return new F41Writer();
48 | }
49 |
50 | public static final String X_FIELDS = "x-fds";
51 | public static final String X_CLASSES = "x-cls";
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F40Format.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F40Format.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | /**
31 | * @author Roman Makarchuk
32 | */
33 | public class F40Format extends Format {
34 |
35 | public F40Format() {
36 | addSupportedFeature(FeaturesHolder.ConstInfo);
37 | addSupportedFeature(FeaturesHolder.TigerInfo);
38 | addSupportedFeature(FeaturesHolder.MergeModeSupported);
39 | addSupportedFeature(FeaturesHolder.BuildMembers);
40 | addSupportedFeature(FeaturesHolder.ListOfHiders);
41 | }
42 |
43 | public String getVersion() {
44 | return "#Signature file v4.0";
45 | }
46 |
47 | public Reader getReader() {
48 | return new F40Reader(this);
49 | }
50 |
51 | public Writer getWriter() {
52 | return new F40Writer();
53 | }
54 |
55 | public static final String HIDDEN_FIELDS = "hfds";
56 | public static final String HIDDEN_CLASSES = "hcls";
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/remote/RemoteLoadManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.remote;
29 |
30 | import com.sun.tdk.signaturetest.loaders.ReflClassDescrLoader;
31 |
32 | import java.io.IOException;
33 | import java.io.ObjectOutputStream;
34 | import java.io.OutputStream;
35 |
36 | /**
37 | * @author Sergey Borodin
38 | */
39 | public class RemoteLoadManager {
40 |
41 | public static void writeClassDescription(String name, OutputStream out) {
42 | ReflClassDescrLoader loader = new ReflClassDescrLoader();
43 | Object descr;
44 | try {
45 | descr = loader.load(name);
46 | }
47 | catch (ClassNotFoundException e) {
48 | descr = e;
49 | } catch (RuntimeException t) {
50 | descr = t;
51 | }
52 |
53 | try {
54 | ObjectOutputStream objOut = new ObjectOutputStream(out);
55 | objOut.writeObject(descr);
56 | objOut.close();
57 | }
58 | catch (IOException e) {
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/resources/com/sun/tdk/signaturetest/util/i18n.properties:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 | #
5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 | #
8 | # This code is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License version 2 only, as
10 | # published by the Free Software Foundation. Sun designates this
11 | # particular file as subject to the "Classpath" exception as provided
12 | # by Sun in the LICENSE file that accompanied this code.
13 | #
14 | # This code is distributed in the hope that it will be useful, but WITHOUT
15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 | # version 2 for more details (a copy is included in the LICENSE file that
18 | # accompanied this code).
19 | #
20 | # You should have received a copy of the GNU General Public License version
21 | # 2 along with this work; if not, write to the Free Software Foundation,
22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
25 | # CA 95054 USA or visit www.sun.com if you need additional information or
26 | # have any questions.
27 | #
28 |
29 | CommandLineParser.error.decoder.explicit.notfound=Explicitly defined public method {0}(String option, String[] params) for {1} not found in the class {2}.
30 | CommandLineParser.error.decoder.default.notfound=No public decoder method found for the option {0} in the class {1}. Please, check option name or add decoder.
31 | CommandLineParser.error.decoder.failed=Decoding parameters for {0} failed: {1}.
32 |
33 | CommandLineParser.error.option.duplicate=Duplicate option found {0}.
34 | CommandLineParser.error.option.unknown=Unknown option {0}.
35 | CommandLineParser.error.option.noprefix=Option {0} must always start with prefix.
36 | CommandLineParser.error.option.required=Option {0} required.
37 | CommandLineParser.error.option.require_more_parameters=At least {1} parameters should be specified for {0} option.
38 | CommandLineParser.error.option.require_less_parameters=Too many parameters specified for {0} option. Required at most {1} parameters.
39 | CommandLineParser.error.option.require_no_parameters=Option {0} does not accept any parameters.
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/errors/Chain.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.errors;
29 |
30 | import java.util.List;
31 | import java.util.TreeSet;
32 |
33 |
34 | /**
35 | *
36 | * @author Sergey Glazyrin
37 | * @author Mikhail Ershov
38 | */
39 | public class Chain {
40 |
41 | private List mainList;
42 | private TreeSet processedMessages;
43 | private TreeSet newMessages;
44 |
45 | void setMessageProcessed(ErrorFormatter.Message m) {
46 | processedMessages.add(m);
47 | }
48 |
49 | void finishProcessing() {
50 | mainList.removeAll(processedMessages);
51 | processedMessages.clear();
52 | mainList.addAll(newMessages);
53 | newMessages.clear();
54 | }
55 |
56 | void addMessage(ErrorFormatter.Message newM) {
57 | newMessages.add(newM);
58 | }
59 |
60 | Chain(List failedMessages) {
61 | mainList = failedMessages;
62 | processedMessages = new TreeSet();
63 | newMessages = new TreeSet();
64 | }
65 |
66 | public void setMessagesProcessed(List l) {
67 | processedMessages.addAll(l);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/Version.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest;
29 |
30 | import com.sun.tdk.signaturetest.util.I18NResourceBundle;
31 |
32 | public class Version {
33 |
34 | private static I18NResourceBundle i18n =
35 | I18NResourceBundle.getBundleForClass(Version.class);
36 |
37 | // the following constatnts should be filled in by the build script
38 | public static final String Number="2.2";
39 | public static final String build_time="";
40 | public static final String build_os="";
41 | public static final String build_user="";
42 |
43 | public static String getVersionInfo() {
44 | StringBuffer sb = new StringBuffer();
45 | sb.append(i18n.getString("Main.usage.version", Version.Number) + '\n');
46 | sb.append("=========================\n");
47 | sb.append(i18n.getString("Version.version.build", Version.build_time) + '\n');
48 | sb.append(i18n.getString("Version.version.build_on", Version.build_os) + '\n');
49 | sb.append(i18n.getString("Version.version.build_by", Version.build_user));
50 | return sb.toString();
51 | }
52 |
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/loaders/LoadingHints.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: ClassDescriptionLoader.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.loaders;
29 |
30 | /**
31 | * This is optional interface which ClassDescriptionLoader can implement
32 | * Allows to pass some additional modes to loader for fine tunung
33 | */
34 | public interface LoadingHints {
35 | void addLoadingHint(Hint hint);
36 |
37 | /**
38 | * Says that loader should not read constant values for
39 | * preventing unnecesary class initialization
40 | * Can be used in reflection loaders without constant checking
41 | */
42 | Hint DONT_READ_VALUES = new Hint("DONT_READ_VALUES");
43 |
44 | /**
45 | * Says that loader should read synthetic elements
46 | */
47 | Hint READ_SYNTETHIC = new Hint("RAED_SYNTHETIC");
48 |
49 | /**
50 | * Says that loader should read bridge methods
51 | */
52 | Hint READ_BRIDGE = new Hint("READ_BRIDGE");
53 |
54 | /**
55 | * Read annotations even inside methods bodies
56 | */
57 | Hint READ_ANY_ANNOTATIONS = new Hint("READ_ANY_ANNOTATIONS");
58 |
59 | public static class Hint {
60 | private String name;
61 |
62 | Hint(String name) {
63 | this.name = name;
64 | }
65 |
66 | public String toString() {
67 | return "Hint:" + name;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/test/java/org/netbeans/apitest/StrictCheckSigtestTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Sun designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Sun in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 | * CA 95054 USA or visit www.sun.com if you need additional information or
23 | * have any questions.
24 | */
25 | package org.netbeans.apitest;
26 |
27 | import java.io.File;
28 | import java.util.ArrayList;
29 | import java.util.Arrays;
30 | import java.util.List;
31 | import junit.framework.Test;
32 | import org.netbeans.junit.NbTestSuite;
33 |
34 | /** Runs all the tests as for compatibility check, but in case we check
35 | * that nothing changed, it does "strictcheck" e.g. the full check for
36 | * mutual compatibility.
37 | *
38 | * @author Jaroslav Tulach
39 | */
40 | public class StrictCheckSigtestTest extends CheckNewSigtestTest {
41 | public StrictCheckSigtestTest(String s) {
42 | super(s);
43 | }
44 |
45 | public static Test suite() {
46 | Test t = null;
47 | // t = new StrictCheckSigtestTest("testJavaAPICanBeRead");
48 | return t != null ? t : new NbTestSuite(StrictCheckSigtestTest.class);
49 | }
50 | @Override
51 | protected final void checkAPIsEqual(String... additionalArgs) throws Exception {
52 | File d1 = new File(getWorkDir(), "dir1");
53 |
54 | File build = new File(getWorkDir(), "build.xml");
55 | extractResource("build.xml", build);
56 |
57 | List args = new ArrayList();
58 | args.addAll(Arrays.asList(additionalArgs));
59 | args.add("-Ddir1=" + d1);
60 | args.add("-Ddir2=" + d1);
61 | args.add("-Dcheck.type=strictcheck");
62 | ExecuteUtils.execute(build, args.toArray(new String[0]));
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/plugin/FormatAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.plugin;
29 |
30 | import com.sun.tdk.signaturetest.sigfile.F41Format;
31 | import com.sun.tdk.signaturetest.sigfile.Reader;
32 | import com.sun.tdk.signaturetest.sigfile.Writer;
33 |
34 | /**
35 | * @author Mikhail Ershov
36 | */
37 | public class FormatAdapter extends F41Format {
38 | private String signature;
39 | protected Reader reader;
40 | protected Writer writer;
41 |
42 | public FormatAdapter(String signature) {
43 | this.signature = signature;
44 | init();
45 | }
46 |
47 | public String getVersion() {
48 | return signature;
49 | }
50 |
51 | public Reader getReader() {
52 | return reader;
53 | }
54 |
55 | public Writer getWriter() {
56 | return writer;
57 | }
58 |
59 | public void setReader(Reader r) {
60 | reader = r;
61 | }
62 |
63 | public void setWriter(Writer w) {
64 | writer = w;
65 | }
66 |
67 | protected void init() {
68 | reader = new ReaderAdapter(this);
69 | writer = new WriterAdapter(this);
70 | }
71 |
72 | // extend access level from protected to public
73 | public void addSupportedFeature(Feature feature) {
74 | super.addSupportedFeature(feature);
75 | }
76 |
77 | // extend access level from protected to public
78 | public void removeSupportedFeature(Feature feature) {
79 | super.removeSupportedFeature(feature);
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/classpath/Classpath.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: Classpath.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.classpath;
29 |
30 | import java.io.IOException;
31 | import java.io.InputStream;
32 |
33 | /**
34 | * @author Maxim Sokolnikov
35 | * @author Serguei Ivashin
36 | * @author Roman Makarchuk
37 | */
38 | public interface Classpath {
39 |
40 | /**
41 | * Initialize the module with given parameter: classPath.
42 | *
43 | * @param classPath parameter provided to initialize module (usually a directory
44 | * or file classPath).
45 | */
46 | public void init(String classPath) throws IOException;
47 |
48 | /**
49 | * Free resources used (if any) or do nothing.
50 | */
51 | public void close();
52 |
53 | /**
54 | * @return true if more classes available
55 | */
56 | public boolean hasNext();
57 |
58 | /**
59 | * Return name of the next available class.
60 | *
61 | * @return Class qualified name
62 | */
63 | public String nextClassName();
64 |
65 | /**
66 | * Reset enumeration of classes which are found by this module.
67 | */
68 | public void setListToBegin();
69 |
70 | /**
71 | * Returns InputStream instance providing bytecode for the required class.
72 | * If classpath has several classes with the same qualified name, an implementation must always
73 | * return first class in the path
74 | */
75 |
76 | public InputStream findClass(String qualifiedClassName) throws IOException, ClassNotFoundException;
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/loaders/VirtualClassDescriptionLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.loaders;
29 |
30 | import com.sun.tdk.signaturetest.core.ClassDescriptionLoader;
31 | import com.sun.tdk.signaturetest.model.ClassDescription;
32 | import com.sun.tdk.signaturetest.sigfile.FeaturesHolder;
33 |
34 | import java.util.Iterator;
35 | import java.util.Map;
36 | import java.util.TreeMap;
37 |
38 | /**
39 | * An abstract class loader that stores and restores classes to/from internal cache
40 | *
41 | * @author Roman Makarchuk
42 | * @author Mikhail Ershov
43 | */
44 | public class VirtualClassDescriptionLoader extends FeaturesHolder implements ClassDescriptionLoader {
45 |
46 | private Map classDescriptions;
47 |
48 | public VirtualClassDescriptionLoader() {
49 | this.classDescriptions = new TreeMap();
50 | }
51 |
52 | public ClassDescription load(String className) throws ClassNotFoundException {
53 | ClassDescription cl = (ClassDescription) classDescriptions.get(className);
54 | if (cl == null)
55 | throw new ClassNotFoundException(className);
56 | return cl;
57 | }
58 |
59 | public void add(ClassDescription cls) {
60 | classDescriptions.put(cls.getQualifiedName(), cls);
61 | }
62 |
63 | public Iterator getClassIterator() {
64 | return classDescriptions.values().iterator();
65 | }
66 |
67 | public void remove(ClassDescription cls) {
68 | remove(cls.getQualifiedName());
69 | }
70 |
71 | public void remove(String clsName) {
72 | classDescriptions.remove(clsName);
73 | }
74 |
75 | public void cleanUp() {
76 | classDescriptions.clear();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/netbeans/apitest/ListCtSym.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Sun designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Sun in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 | * CA 95054 USA or visit www.sun.com if you need additional information or
23 | * have any questions.
24 | */
25 | package org.netbeans.apitest;
26 |
27 | import java.io.File;
28 | import java.io.FileWriter;
29 | import java.io.IOException;
30 | import java.io.Writer;
31 |
32 | final class ListCtSym {
33 | public static void main(String... args) throws Exception {
34 | File lsR = new File(args[0]);
35 | File dir = new File(args[1]);
36 | int depth = Integer.parseInt(args[2]);
37 |
38 | Writer w = new FileWriter(lsR);
39 | dumpDir(w, dir, null, depth);
40 | w.close();
41 | }
42 |
43 | private static void dumpDir(Writer w, File dir, String prefix, int depth) throws IOException {
44 | File[] children = dir.listFiles();
45 | if (depth <= 0 || children == null) {
46 | return;
47 | }
48 | int minusOneDepth = depth - 1;
49 | for (File ch : children) {
50 | String newPrefix = prefix == null ? ch.getName() : prefix + "/" + ch.getName();
51 | if (minusOneDepth == 0) {
52 | w.append(newPrefix).append("\n");
53 | } else {
54 | if (ch.isDirectory()) {
55 | dumpDir(w, ch, newPrefix, minusOneDepth);
56 | }
57 | }
58 | }
59 | }
60 |
61 | static Integer parseReleaseInteger(String release) {
62 | if (release == null) {
63 | return null;
64 | }
65 | String r;
66 | if (release.startsWith("1.")) {
67 | r = release.substring(2);
68 | } else {
69 | r = release;
70 | }
71 | try {
72 | return Integer.parseInt(r);
73 | } catch (NumberFormatException ex) {
74 | return null;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/core/PrimitiveTypes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: PrimitiveTypes.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.core;
29 |
30 | /**
31 | * @author Mikhail Ershov
32 | */
33 | public class PrimitiveTypes {
34 |
35 | public static boolean isPrimitive(String jlsType) {
36 |
37 | for(int i=0; i args = new ArrayList();
63 | args.add("all-property");
64 | args.addAll(Arrays.asList(additionalArgs));
65 | args.add("-Ddir1=" + d1);
66 | args.add("-Ddir2=" + d2);
67 | ExecuteUtils.execute(build, args.toArray(new String[0]));
68 | }
69 |
70 | @Override
71 | public void testGenerateVersionNumberAsJunit() throws Exception {}
72 | @Override
73 | public void testGenerateVersionNumber() throws Exception {}
74 | @Override
75 | public void testNoFailuresIfInXMLIf() {}
76 |
77 | }
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/merge/MergedSigFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.merge;
29 |
30 | import com.sun.tdk.signaturetest.core.ClassHierarchy;
31 | import com.sun.tdk.signaturetest.core.ClassHierarchyImpl;
32 | import com.sun.tdk.signaturetest.core.Log;
33 | import com.sun.tdk.signaturetest.model.ClassDescription;
34 | import com.sun.tdk.signaturetest.sigfile.MultipleFileReader;
35 |
36 | import java.io.IOException;
37 | import java.util.HashMap;
38 | import java.util.logging.Level;
39 | import java.util.logging.Logger;
40 |
41 | public class MergedSigFile {
42 |
43 | private ClassHierarchy ch;
44 | private MultipleFileReader loader;
45 | private HashMap set;
46 |
47 | public MergedSigFile(MultipleFileReader loader , Log log) {
48 | this.loader = loader;
49 | ch = new ClassHierarchyImpl(loader, ClassHierarchy.ALL_PUBLIC);
50 | }
51 |
52 | public HashMap getClassSet() {
53 | if (set == null) {
54 | set = new HashMap();
55 | loader.rewind();
56 | ClassDescription cd = null;
57 | do {
58 | try {
59 | cd = loader.nextClass();
60 | if (cd != null) {
61 | set.put(cd.getQualifiedName(), cd);
62 | }
63 | } catch (IOException ex) {
64 | Logger.getLogger("global").log(Level.SEVERE, null, ex);
65 | break;
66 | }
67 | } while(cd != null);
68 | }
69 | return set;
70 | }
71 |
72 | public ClassHierarchy getClassHierarchy() {
73 | return ch;
74 | }
75 |
76 | MultipleFileReader getLoader() {
77 | return loader;
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/model/SuperClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: SuperClass.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.model;
29 |
30 | import com.sun.tdk.signaturetest.util.SwissKnife;
31 |
32 | /**
33 | * @author Roman Makarchuk
34 | */
35 | public final class SuperClass extends MemberDescription {
36 | public SuperClass() {
37 | super(MemberType.SUPERCLASS, CLASS_DELIMITER);
38 | }
39 |
40 | // NOTE: Change this method carefully if you changed the code,
41 | // please, update the method isCompatible() in order it works as previously
42 | public boolean equals(Object o) {
43 | // == used instead of equals() because name is always assigned via String.intern() call
44 | return o instanceof SuperClass && name==((SuperClass) o).name;
45 | }
46 |
47 | public int hashCode() {
48 | return name.hashCode();
49 | }
50 |
51 | public String getQualifiedName() {
52 | return name;
53 | }
54 |
55 | public String getName() {
56 | return getClassShortName(name);
57 | }
58 |
59 | public boolean isCompatible(MemberDescription m) {
60 |
61 | if (!equals(m))
62 | throw new IllegalArgumentException("Only equal members can be checked for compatibility!");
63 |
64 | return SwissKnife.equals(typeParameters, m.typeParameters);
65 | }
66 |
67 | public boolean isSuperClass() {
68 | return true;
69 | }
70 |
71 | public String toString() {
72 |
73 | StringBuffer buf = new StringBuffer();
74 |
75 | buf.append("superclass");
76 |
77 | buf.append(' ');
78 | buf.append(name);
79 |
80 | if (typeParameters != null)
81 | buf.append(typeParameters);
82 |
83 | return buf.toString();
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/resources/com/sun/tdk/signaturetest/loaders/i18n.properties:
--------------------------------------------------------------------------------
1 | #
2 | # $Id: i18n.properties 4516 2008-03-17 18:48:27Z eg216457 $
3 | #
4 | #
5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 | #
8 | # This code is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License version 2 only, as
10 | # published by the Free Software Foundation. Sun designates this
11 | # particular file as subject to the "Classpath" exception as provided
12 | # by Sun in the LICENSE file that accompanied this code.
13 | #
14 | # This code is distributed in the hope that it will be useful, but WITHOUT
15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 | # version 2 for more details (a copy is included in the LICENSE file that
18 | # accompanied this code).
19 | #
20 | # You should have received a copy of the GNU General Public License version
21 | # 2 along with this work; if not, write to the Free Software Foundation,
22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
25 | # CA 95054 USA or visit www.sun.com if you need additional information or
26 | # have any questions.
27 | #
28 |
29 | BinaryClassDescrLoader.error.magicnum=wrong magic: {0}, expected {1}
30 | BinaryClassDescrLoader.error.const=Constant {0} expected, but {1} found
31 | BinaryClassDescrLoader.error.cpoutofbounds=Index out of the constant pool bounds
32 | BinaryClassDescrLoader.error.enclosing=Problem with enclosing class for {0}
33 | BinaryClassDescrLoader.error.attribute=Error in signature attribute ''{0}'' of classfile ''{1}''
34 | BinaryClassDescrLoader.message.incorrectformat=Incorrect format of method/constructor parameters in class
35 | BinaryClassDescrLoader.error.enclosing_class_not_found=Enclosing class for class {0} has not been found. If class {0} is a normal class(not nested), it would be better to find another name for it!
36 |
37 | BinaryClassDescrLoader.error.annotnotfound=? annotation {0}
38 | BinaryClassDescrLoader.error.unknownannot=Annotation member value tag = {0}
39 | BinaryClassDescrLoader.message.attribute={0} attribute found in classfile ''{1}'' version {2} : {3}
40 | BinaryClassDescrLoader.error.unknownconst=Unknown constant type! Type ID {0}
41 |
42 | TigerRefgClassDescrLoader.message.synthetic_constr_skipped=Synthetic constructor {0} skipped
43 | TigerRefgClassDescrLoader.message.synthetic_field_skipped=Synthetic field {0} skipped
44 | TigerRefgClassDescrLoader.message.synthetic_method_skipped=Synthetic method {0} skipped
45 |
46 | TigerRefgClassDescrLoader.error.invalidannot=Invalid annotation: {0}
47 |
48 | BinaryClassDescrLoader.message.bridge=Bridge method {0} skipped
49 | BinaryClassDescrLoader.message.synthetic_constr_skipped=Synthetic constructor {0} skipped
50 | BinaryClassDescrLoader.message.synthetic_field_skipped=Synthetic field {0} skipped
51 | BinaryClassDescrLoader.message.synthetic_method_skipped=Synthetic method {0} skipped
52 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/classpath/ClasspathEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: ClasspathEntry.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.classpath;
29 |
30 | import java.util.Iterator;
31 | import java.util.LinkedHashSet;
32 |
33 | /**
34 | * @author Maxim Sokolnikov
35 | * @author Serguei Ivashin
36 | */
37 | public abstract class ClasspathEntry implements Classpath {
38 |
39 | protected static final String JAVA_CLASSFILE_EXTENSION = ".class";
40 | protected static final int JAVA_CLASSFILE_EXTENSION_LEN = JAVA_CLASSFILE_EXTENSION.length();
41 | final protected ClasspathEntry previousEntry;
42 |
43 |
44 | protected ClasspathEntry(ClasspathEntry previousEntry) {
45 | this.previousEntry = previousEntry;
46 | }
47 |
48 | /**
49 | * Qualified names for all those classes found in this directory.
50 | */
51 | protected LinkedHashSet classes;
52 |
53 | /**
54 | * This currentPosition iterator is used to browse classes
55 | */
56 | protected Iterator currentPosition;
57 |
58 | public boolean hasNext() {
59 | return currentPosition.hasNext();
60 | }
61 |
62 | public String nextClassName() {
63 | return (String) currentPosition.next();
64 | }
65 |
66 | /**
67 | * Reset enumeration of classes found in this
68 | * ClasspathEntry.
69 | *
70 | * @see #nextClassName()
71 | * @see #findClass(String)
72 | */
73 |
74 | public void setListToBegin() {
75 | currentPosition = classes.iterator();
76 | }
77 |
78 | protected boolean contains(String className) {
79 | return classes.contains(className) || (previousEntry != null && previousEntry.contains(className));
80 | }
81 |
82 | public boolean isEmpty() {
83 | return classes.isEmpty();
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/core/Exclude.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: Exclude.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.core;
29 |
30 | import com.sun.tdk.signaturetest.model.ClassDescription;
31 | import com.sun.tdk.signaturetest.model.MemberDescription;
32 |
33 | /**
34 | * The exclusion plugin allow ignore classes, methods, fields during signature check.
35 | * The SignatureTest use property "exclude.plugin" to find implementation of plugin.
36 | * Plugin can use specific command-line arguments to define exclusion criteria.
37 | * The method 'check' is invoked by SignatureTest for each API item.
38 | *
39 | * @author Leonid Mesnik
40 | */
41 | public interface Exclude {
42 |
43 | /**
44 | * This method parses parameters specific to exclusion plugin
45 | * @param args vector of all parameters
46 | * @return vector of parameters which can't be parsed by this extension
47 | */
48 | public String[] parseParameters(String[] args);
49 |
50 |
51 | /**
52 | * Checks if the given signature is excluded.
53 | * @param testedClass the full qualified name of class being testing now
54 | * @param signature full qualified signature of class, method or field which is tested,
55 | * for methods and fields signature includes the name of class where this member
56 | * is declared, for classes this signature is it name
57 | * @throws ExcludeException if signature is to be excluded with message which is
58 | * used by SignatureTest for diagnostic messages
59 | */
60 | public void check(ClassDescription testedClass, MemberDescription signature) throws ExcludeException;
61 |
62 |
63 | /**
64 | * This method is invoked after all checks, to get plugin's summary report.
65 | * This report is logged.
66 | * @return report for plugin work or null if no report is needed.
67 | */
68 | public String report();
69 | }
70 |
--------------------------------------------------------------------------------
/src/test/java/org/netbeans/apitest/APIWithReleaseTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Sun designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Sun in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 | * CA 95054 USA or visit www.sun.com if you need additional information or
23 | * have any questions.
24 | */
25 | package org.netbeans.apitest;
26 |
27 | import junit.framework.Test;
28 | import org.netbeans.junit.NbTestSuite;
29 |
30 | /**
31 | *
32 | * @author Jaroslav Tulach
33 | */
34 | public class APIWithReleaseTest extends APITest {
35 | public APIWithReleaseTest(String s) {
36 | super(s);
37 | }
38 |
39 | public static Test suite() {
40 | Test t = null;
41 | // t = new APIWithReleaseTest("testStrictNestedInterfaces");
42 | if (t == null) {
43 | t = new NbTestSuite(APIWithReleaseTest.class);
44 | }
45 | return t;
46 | }
47 |
48 | @Override
49 | protected String buildScript() {
50 | return "build-with-release.xml";
51 | }
52 |
53 | @Override
54 | protected String generateRelease() {
55 | return "14";
56 | }
57 |
58 | @Override
59 | protected String checkRelease() {
60 | return "15";
61 | }
62 |
63 | public void testDetectChangeInCharSequence() throws Exception {
64 | String c1 =
65 | "package ahoj;" +
66 | "public interface I extends CharSequence {" +
67 | " public void get();" +
68 | "}";
69 | createFile(1, "I.java", c1);
70 |
71 |
72 | String c2 =
73 | "package ahoj;" +
74 | "public interface I extends CharSequence {" +
75 | " public void get();" +
76 | "}";
77 | createFile(2, "I.java", c2);
78 |
79 | try {
80 | compareAPIs(1, 2, "-Dcheck.package=ahoj.*", "-Dcheck.type=strictcheck");
81 | fail("CharSequence.isEmpty() was added in JDK15 and that should be detected");
82 | } catch (ExecuteUtils.ExecutionError ex) {
83 | String out = ex.getStdErr().replace('\n', ' ');
84 | assertTrue(out, out.matches(".*Added Methods.*ahoj.I.*method public boolean java.lang.CharSequence.isEmpty().*"));
85 | }
86 | }
87 |
88 | }
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/errors/BCUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 |
29 | package com.sun.tdk.signaturetest.errors;
30 |
31 | import com.sun.tdk.signaturetest.model.ClassDescription;
32 | import com.sun.tdk.signaturetest.model.FieldDescr;
33 | import com.sun.tdk.signaturetest.model.MethodDescr;
34 |
35 | import java.util.List;
36 |
37 | /**
38 | * @author Mikhail Ershov
39 | */
40 | abstract class FieldPairedHandler extends PairedHandler {
41 | protected FieldDescr f1;
42 | protected FieldDescr f2;
43 |
44 | boolean acceptMessageList(List l) {
45 | if (!super.acceptMessageList(l))
46 | return false;
47 |
48 | init(l);
49 |
50 | if (m1 instanceof FieldDescr && m2 instanceof FieldDescr) {
51 | f1 = (FieldDescr) m1;
52 | f2 = (FieldDescr) m2;
53 | return true;
54 | }
55 | return false;
56 | }
57 | }
58 |
59 | abstract class MethodPairedHandler extends PairedHandler {
60 | protected MethodDescr meth1;
61 | protected MethodDescr meth2;
62 |
63 | boolean acceptMessageList(List l) {
64 | if (!super.acceptMessageList(l))
65 | return false;
66 | init(l);
67 | if (m1 instanceof MethodDescr && m2 instanceof MethodDescr) {
68 | meth1 = (MethodDescr) m1;
69 | meth2 = (MethodDescr) m2;
70 | return true;
71 | }
72 | return false;
73 | }
74 | }
75 |
76 |
77 | abstract class ClassPairedHandler extends PairedHandler {
78 | protected ClassDescription c1;
79 | protected ClassDescription c2;
80 |
81 | boolean acceptMessageList(List l) {
82 | if (!super.acceptMessageList(l))
83 | return false;
84 |
85 | init(l);
86 |
87 | if (m1 instanceof ClassDescription && m2 instanceof ClassDescription) {
88 | c1 = (ClassDescription) m1;
89 | c2 = (ClassDescription) m2;
90 | return true;
91 | }
92 | return false;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/resources/com/sun/tdk/signaturetest/core/i18n.properties:
--------------------------------------------------------------------------------
1 | #
2 | # $Id: i18n.properties 4504 2008-03-13 16:12:22Z sg215604 $
3 | #
4 | #
5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 | #
8 | # This code is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License version 2 only, as
10 | # published by the Free Software Foundation. Sun designates this
11 | # particular file as subject to the "Classpath" exception as provided
12 | # by Sun in the LICENSE file that accompanied this code.
13 | #
14 | # This code is distributed in the hope that it will be useful, but WITHOUT
15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 | # version 2 for more details (a copy is included in the LICENSE file that
18 | # accompanied this code).
19 | #
20 | # You should have received a copy of the GNU General Public License version
21 | # 2 along with this work; if not, write to the Free Software Foundation,
22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
25 | # CA 95054 USA or visit www.sun.com if you need additional information or
26 | # have any questions.
27 | #
28 |
29 |
30 | ClassCorrector.message.throwslist.changed=THROW LIST FOR {0} CHANGED FROM {1} TO {2}
31 | ClassCorrector.message.returntype.changed=RETURN TYPE FOR {0}::{1} CHANGED FROM {2} TO {3}
32 | ClassCorrector.message.fieldtype.changed=FIELD TYPE FOR {0}::{1} CHANGED FROM {2} TO {3}
33 | ClassCorrector.error.returntype.hidden=Hidden return type (can''t convert) : {0} in {1}
34 | ClassCorrector.error.fieldtype.hidden=Hidden field type (can''t convert) : {0} in {1}
35 | ClassCorrector.error.parametertype.hidden=Hidden class found: {0} in {1} in class {2}
36 | ClassCorrector.error.parametertype.hidden2=Hidden class found: {0} in {1} in class {2}
37 | ClassCorrector.error.missingclass=Warning: class {0} not found. Please, add required jar or directory to the classpath.
38 | ClassCorrector.error.invisible_documented_annotation=Warning: annotation {0} is not public and marked as Documented. Only public annotation should be documented!
39 | ClassCorrector.message.member.moved=CLASS MEMBER {0} MOVED FROM {1} TO {2}
40 | ClassCorrector.message.member.removed=CLASS MEMBER {0}.{1} REMOVED FROM {2} BECAUSE THE SAME MEMBER ALREADY EXISTS IN {3}
41 | ClassCorrector.message.interface.removed=INTERFACE {0} REMOVED FROM {1}
42 | ClassCorrector.message.super.changed=SUPERCLASS FOR {0} CHANGED FROM {1} TO {2}
43 | ClassCorrector.message.const.removed=CONST {0} REMOVED FROM {1}
44 | ClassCorrector.error.class.useless_abst_public_class=Warning: public class {0} can''t be extended because contains the following member: {1}
45 |
46 | Erasurator.error.unresolved=Unresolved parameter {0}
47 |
48 | MemberCollectionBuilder.warn.returntype.notresolved=The return type {0} can''t be resolved
49 |
50 | MemberCollectionBuilder.message.bridge=Bridge method {0} skipped
51 | MemberCollectionBuilder.message.synthetic_constr_skipped=Synthetic constructor {0} skipped
52 | MemberCollectionBuilder.message.synthetic_method_skipped=Synthetic method {0} skipped
53 |
54 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/core/ClassHierarchy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.core;
29 |
30 | import com.sun.tdk.signaturetest.model.ClassDescription;
31 | import com.sun.tdk.signaturetest.model.MethodDescr;
32 |
33 | import java.util.List;
34 | import java.util.Set;
35 |
36 | /**
37 | * @author Roman Makarchuk
38 | */
39 | public interface ClassHierarchy extends ClassDescriptionLoader {
40 |
41 | // track mode
42 | public static final int ALL_PUBLIC = 2;
43 |
44 | String getSuperClass(String fqClassName) throws ClassNotFoundException;
45 |
46 | List /* String */ getSuperClasses(String fqClassName) throws ClassNotFoundException;
47 |
48 | String[] getSuperInterfaces(String fqClassName) throws ClassNotFoundException;
49 |
50 | Set /* String */ getAllImplementedInterfaces(String fqClassName) throws ClassNotFoundException;
51 |
52 | String[] getDirectSubclasses(String fqClassName);
53 |
54 | String[] getAllSubclasses(String fqClassName);
55 |
56 | String[] getNestedClasses(String fqClassName);
57 |
58 | boolean isInterface(String fqClassName) throws ClassNotFoundException;
59 |
60 | boolean isAnnotation(String fqClassName) throws ClassNotFoundException;
61 |
62 | int getClassModifiers(String fqClassName) throws ClassNotFoundException;
63 |
64 | boolean isSubclass(String subClassName, String superClassName) throws ClassNotFoundException;
65 |
66 | ClassDescription load(String name) throws ClassNotFoundException;
67 |
68 | boolean isAccessible(ClassDescription c);
69 |
70 | boolean isDocumentedAnnotation(String fqname) throws ClassNotFoundException;
71 |
72 | boolean isAccessible(String fqname) throws ClassNotFoundException;
73 |
74 | boolean isClassVisibleOutside(String fqClassName) throws ClassNotFoundException;
75 | boolean isClassVisibleOutside(ClassDescription cls) throws ClassNotFoundException;
76 |
77 | int getTrackMode();
78 |
79 | boolean isMethodOverriden(MethodDescr md) throws ClassNotFoundException;
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F41Writer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F41Writer.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import com.sun.tdk.signaturetest.model.AnnotationItem;
31 | import com.sun.tdk.signaturetest.model.ClassDescription;
32 | import com.sun.tdk.signaturetest.model.MemberDescription;
33 | import com.sun.tdk.signaturetest.model.MemberType;
34 | import com.sun.tdk.signaturetest.model.Modifier;
35 |
36 | public class F41Writer extends F40Writer {
37 |
38 | public F41Writer() {
39 | format = new F41Format();
40 | }
41 |
42 | protected void writeHiders(ClassDescription classDescription, StringBuffer buf) {
43 | super.writeHiders(classDescription, buf);
44 | writeInternalMembers(buf, F41Format.X_FIELDS, classDescription.getXFields());
45 | writeInternalMembers(buf, F41Format.X_CLASSES, classDescription.getXClasses());
46 | }
47 |
48 |
49 | protected void write(StringBuffer buf, ClassDescription m) {
50 |
51 | MemberType memberType = m.getMemberType();
52 |
53 | buf.append(memberType);
54 |
55 | String modifiers = Modifier.toString(memberType, m.getModifiers(), true);
56 | if (modifiers.length() != 0) {
57 | buf.append(' ');
58 | buf.append(modifiers);
59 | }
60 |
61 | buf.append(' ');
62 | buf.append(m.getQualifiedName());
63 |
64 | String typeParameters = m.getTypeParameters();
65 |
66 | if (typeParameters != null)
67 | buf.append(typeParameters);
68 |
69 | if (m.getOuterClass() != null &&
70 | !m.getOuterClass().equals(MemberDescription.NO_DECLARING_CLASS)) {
71 | buf.append("\n " + ClassDescription.OUTER_PREFIX + " ");
72 | buf.append(m.getOuterClass());
73 | }
74 |
75 | AnnotationItem[] annoList = m.getAnnoList();
76 | for (int i = 0; i < annoList.length; ++i) {
77 | buf.append("\n ");
78 | buf.append(annoList[i]);
79 | }
80 | }
81 |
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/classpath/Release.java:
--------------------------------------------------------------------------------
1 | package com.sun.tdk.signaturetest.classpath;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | public final class Release {
13 | public static final Release BOOT_CLASS_PATH = new Release('0', null);
14 |
15 | private final char version;
16 | private final String[] prefixes;
17 |
18 | private Release(char version, String... prefixes) {
19 | this.version = version;
20 | this.prefixes = prefixes;
21 | }
22 |
23 | /**
24 | * Finds version of the JDK API.
25 | * @param version 6, 7, 8, 9, ..., 11, ... 15
26 | * @return found version or null
27 | */
28 | public static Release find(int version) {
29 | if (version > 15) {
30 | return null;
31 | }
32 | char ch = (char) (version < 10 ? '0' + version : 'A' + (version - 10));
33 | return RELEASES.get(ch);
34 | }
35 |
36 | InputStream findClass(String name) {
37 | if (prefixes == null) {
38 | final String resourceName = name.replace('.', '/') + ".class";
39 | return ClassLoader.getSystemClassLoader().getResourceAsStream(resourceName);
40 | } else {
41 | for (String p : prefixes) {
42 | final String resourceName = "/META-INF/sigtest/" + p + "/" + name.replace('.', '/') + ".sig";
43 | InputStream is = Release.class.getResourceAsStream(resourceName);
44 | if (is != null) {
45 | return is;
46 | }
47 | }
48 | return null;
49 | }
50 |
51 | }
52 |
53 | private static final Map RELEASES;
54 | static {
55 | List lines = new ArrayList<>();
56 | try {
57 | try (BufferedReader r = new BufferedReader(new InputStreamReader(Release.class.getResourceAsStream("/META-INF/sigtest.ls")))) {
58 | for (;;) {
59 | String l = r.readLine();
60 | if (l == null) {
61 | break;
62 | }
63 | lines.add(l);
64 | }
65 | }
66 | } catch (IOException ex) {
67 | throw new InternalError(ex);
68 | }
69 |
70 | Map> prefixes = new HashMap<>();
71 | for (String l : lines) {
72 | String[] versionsDir = l.split("/");
73 | String versions = versionsDir[0];
74 | for (int i = 0; i < versions.length(); i++) {
75 | Character ch = versions.charAt(i);
76 | List arr = prefixes.get(ch);
77 | if (arr == null) {
78 | arr = new ArrayList<>();
79 | prefixes.put(ch, arr);
80 | }
81 | arr.add(l);
82 | }
83 | }
84 |
85 | Map releases = new HashMap<>();
86 | for (Map.Entry> entry : prefixes.entrySet()) {
87 | Character key = entry.getKey();
88 | List value = entry.getValue();
89 | releases.put(key, new Release(key, value.toArray(new String[0])));
90 | }
91 |
92 | RELEASES = releases;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/apicover/markup/Adapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.apicover.markup;
29 |
30 | import com.sun.tdk.signaturetest.model.AnnotationItem;
31 | import com.sun.tdk.signaturetest.model.MemberType;
32 | import com.sun.tdk.signaturetest.model.Modifier;
33 | import com.sun.tdk.signaturetest.plugin.FormatAdapter;
34 | import com.sun.tdk.signaturetest.plugin.ReaderAdapter;
35 | import com.sun.tdk.signaturetest.sigfile.F40Format;
36 | import com.sun.tdk.signaturetest.sigfile.FileManager;
37 |
38 | /**
39 | * @author Mikhail Ershov
40 | */
41 | public class Adapter {
42 |
43 | public Adapter(FileManager fm) {
44 |
45 | // add pseudo-modifier
46 | coverIgnore = new Modifier("!cover-ignore", true);
47 |
48 | // allow this for any type of elements
49 | for (MemberType mt : MemberType.knownTypes) {
50 | mt.setModifiersMask(mt.getModifiersMask() | coverIgnore.getValue());
51 | }
52 | // add format
53 | FormatAdapter f = new FormatAdapter("#APICover file v4.1");
54 | f.setReader(new ReaderAdapter(f) {
55 |
56 | boolean covOn = false;
57 |
58 | protected String preprocessLine(String currentLine) {
59 |
60 | if (currentLine != null) {
61 | String st = currentLine.trim();
62 | if (st.equals("#coverage off")) {
63 | covOn = false;
64 | } else if (st.equals("#coverage on")) {
65 | covOn = true;
66 | } else if (!"".equals(st) && !covOn && !st.startsWith("#")) {
67 | if (!st.startsWith(AnnotationItem.ANNOTATION_PREFIX) &&
68 | !st.startsWith(FormatAdapter.HIDDEN_FIELDS) &&
69 | !st.startsWith(FormatAdapter.HIDDEN_CLASSES))
70 | currentLine = currentLine.replaceFirst(" ", " " + coverIgnore.toString() + " ");
71 | }
72 | }
73 | return super.preprocessLine(currentLine);
74 | }
75 | });
76 | fm.addFormat(f, false);
77 | }
78 |
79 | public static Modifier coverIgnore;
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/model/InnerDescr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: InnerDescr.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.model;
29 |
30 | /**
31 | * @author Roman Makarchuk
32 | */
33 |
34 | public final class InnerDescr extends MemberDescription {
35 |
36 | public static final InnerDescr[] EMPTY_ARRAY = new InnerDescr[0];
37 |
38 | public InnerDescr() {
39 | super(MemberType.INNER, CLASS_DELIMITER);
40 | }
41 |
42 | public InnerDescr(String fullQualifiedName, String outerName, int modif) {
43 | this();
44 | setupClassName(fullQualifiedName, outerName);
45 | setModifiers(modif);
46 | }
47 |
48 | // NOTE: Change this method carefully if you changed the code,
49 | // please, update the method isCompatible() in order it works as previously
50 |
51 | public boolean equals(Object o) {
52 | // == used instead of equals() because name is always assigned via String.intern() call
53 | return o instanceof InnerDescr && name==((InnerDescr) o).name;
54 | }
55 |
56 | public int hashCode() {
57 | return name.hashCode();
58 | }
59 |
60 | public boolean isCompatible(MemberDescription m) {
61 |
62 | if (!equals(m))
63 | throw new IllegalArgumentException("Only equal members can be checked for compatibility!");
64 |
65 | return memberType.isCompatible(getModifiers(), m.getModifiers());
66 | }
67 |
68 | public boolean isInner() {
69 | return true;
70 | }
71 |
72 | public String toString() {
73 |
74 | StringBuffer buf = new StringBuffer();
75 |
76 |
77 | if (hasModifier(Modifier.STATIC))
78 | buf.append("nested");
79 | else
80 | buf.append("inner");
81 |
82 | String modifiers = Modifier.toString(memberType, getModifiers(), true);
83 | if (modifiers.length() != 0) {
84 | buf.append(' ');
85 | buf.append(modifiers);
86 | }
87 |
88 | buf.append(' ');
89 | buf.append(declaringClass);
90 | buf.append(delimiter);
91 | buf.append(name);
92 |
93 | return buf.toString();
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/model/SuperInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: SuperInterface.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.model;
29 |
30 | import com.sun.tdk.signaturetest.util.SwissKnife;
31 |
32 | /**
33 | * @author Roman Makarchuk
34 | */
35 | public final class SuperInterface extends MemberDescription {
36 |
37 | public static final SuperInterface[] EMPTY_ARRAY = new SuperInterface[0];
38 |
39 | public SuperInterface() {
40 | super(MemberType.SUPERINTERFACE, CLASS_DELIMITER);
41 | }
42 |
43 | // NOTE: Change this method carefully if you changed the code,
44 | // please, update the method isCompatible() in order it works as previously
45 | public boolean equals(Object o) {
46 | if (!(o instanceof SuperInterface))
47 | return false;
48 |
49 | return name == ((SuperInterface)o).name;
50 | }
51 |
52 | public int hashCode() {
53 | return name.hashCode();
54 | }
55 |
56 | public String getQualifiedName() {
57 | return name;
58 | }
59 |
60 | public String getName() {
61 | return getClassShortName(name);
62 | }
63 |
64 | public boolean isCompatible(MemberDescription m) {
65 | if (!equals(m))
66 | throw new IllegalArgumentException("Only equal members can be checked for compatibility!");
67 |
68 | return SwissKnife.equals(typeParameters, m.typeParameters);
69 | }
70 |
71 | public boolean isSuperInterface() {
72 | return true;
73 | }
74 |
75 |
76 | public boolean isDirect() {
77 | return direct;
78 | }
79 |
80 | public void setDirect(boolean direct) {
81 | this.direct = direct;
82 | }
83 |
84 | private boolean direct;
85 |
86 | public String toString() {
87 |
88 | StringBuffer buf = new StringBuffer();
89 |
90 | buf.append("interface");
91 |
92 | if (isDirect())
93 | buf.append(" @");
94 |
95 | buf.append(' ');
96 | buf.append(name);
97 |
98 | if (typeParameters != null)
99 | buf.append(typeParameters);
100 |
101 | return buf.toString();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/FeaturesHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import java.util.*;
31 |
32 | public class FeaturesHolder {
33 | private Set supportedFeatures;
34 | public static final Feature ConstInfo = new Feature("#NoConstInfo");
35 | public static final Feature TigerInfo = new Feature("#NoTigerFeaturesInfo");
36 | public static final Feature MergeModeSupported = new Feature("#MergeModeSupported");
37 | public static final Feature BuildMembers = new Feature("#BuildMembers");
38 | public static final Feature NonStaticConstants = new Feature("#NonStaticConstants");
39 | public static final Feature ListOfHiders = new Feature("#ListOfHiders");
40 | public static final Feature XHiders = new Feature("#XHiders");
41 | public static final Feature OuterClasses = new Feature("#OuterClasses");
42 |
43 | public void addSupportedFeature(Feature feature) {
44 | ensureInitialized();
45 | supportedFeatures.add(feature);
46 | }
47 |
48 | public Set getSupportedFeatures() {
49 | ensureInitialized();
50 | return supportedFeatures;
51 | }
52 |
53 | private void ensureInitialized() {
54 | if (supportedFeatures == null) {
55 | supportedFeatures = new HashSet();
56 | }
57 | }
58 |
59 | protected void removeSupportedFeature(Feature feature) {
60 | ensureInitialized();
61 | supportedFeatures.remove(feature);
62 | }
63 |
64 | public boolean isFeatureSupported(Feature feature) {
65 | ensureInitialized();
66 | return supportedFeatures.contains(feature);
67 | }
68 |
69 | protected boolean isInitialized() {
70 | return supportedFeatures != null;
71 | }
72 |
73 | public void setFeatures(Set features) {
74 | supportedFeatures = new HashSet(features);
75 | }
76 |
77 | public void retainFeatures(Set features) {
78 | supportedFeatures.retainAll(features);
79 | }
80 |
81 | public static class Feature {
82 | private String pragma;
83 |
84 | private Feature(String pragma) {
85 | this.pragma = pragma;
86 | }
87 |
88 | public String toString() {
89 | return pragma;
90 | }
91 |
92 | boolean match(String line) {
93 | return pragma.equals(line);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/util/OptionInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: OptionInfo.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.util;
29 |
30 | public final class OptionInfo {
31 |
32 | public static final boolean DEFAULT_SENSITIVITY = false;
33 | public static final int UNLIMITED = Integer.MAX_VALUE;
34 |
35 | private boolean required; // the option must be always specified in the command line
36 | private int minCount; // minimum parameters that the option requires
37 | private int maxCount;
38 | private boolean multiple; // the option can be specified several times
39 | private boolean caseSensitive; // is option case sensitive ot not
40 |
41 | public static OptionInfo requiredOption(int paramCount) {
42 | return new OptionInfo(true, paramCount, paramCount, false, DEFAULT_SENSITIVITY);
43 | }
44 |
45 | public static OptionInfo option(int paramCount) {
46 | return new OptionInfo(false, paramCount, paramCount, false, DEFAULT_SENSITIVITY);
47 | }
48 |
49 | public static OptionInfo requiredOptionVariableParams(int min, int max) {
50 | return new OptionInfo(true, min, max, true, DEFAULT_SENSITIVITY);
51 | }
52 |
53 | public static OptionInfo optionVariableParams(int min, int max) {
54 | return new OptionInfo(false, min, max, true, DEFAULT_SENSITIVITY);
55 | }
56 |
57 | public static OptionInfo optionalFlag() {
58 | return new OptionInfo(false, 0, 0, false, DEFAULT_SENSITIVITY);
59 | }
60 |
61 | public OptionInfo(boolean required, int minCount, int maxCount, boolean multiple, boolean isCaseSensitive) {
62 | this.required = required;
63 | this.minCount = minCount;
64 | this.maxCount = maxCount;
65 | this.multiple = multiple;
66 | this.caseSensitive = isCaseSensitive;
67 | }
68 |
69 | public String toKey(String arg) {
70 | String temp = arg;
71 | if (!caseSensitive)
72 | temp = temp.toLowerCase();
73 | return temp;
74 | }
75 |
76 | public int getMinCount() {
77 | return minCount;
78 | }
79 |
80 | public int getMaxCount() {
81 | return maxCount;
82 | }
83 |
84 | public boolean isCaseSentitive() {
85 | return caseSensitive;
86 | }
87 |
88 | public boolean isMultiple() {
89 | return multiple;
90 | }
91 |
92 | public boolean isRequired() {
93 | return required;
94 | }
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/model/PackageDescr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.model;
29 |
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | public class PackageDescr {
34 |
35 | private List classes;
36 | private List subpackages;
37 | private String fqname;
38 | private String name = "";
39 |
40 | public String getQualifiedName() {
41 | return fqname;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public PackageDescr(String fqname) {
49 | this.fqname = fqname;
50 | this.name = fqname.lastIndexOf(".") > 0 ? fqname.substring(fqname.lastIndexOf(".") + 1) : fqname;
51 | this.classes = new ArrayList();
52 | this.subpackages = new ArrayList();
53 | }
54 |
55 | public void add(ClassDescription cd) {
56 | for (int i = 0; i < classes.size(); i++)
57 | if (((ClassDescription) classes.get(i)).getQualifiedName()
58 | .compareTo(cd.getQualifiedName()) > 0) {
59 | classes.add(i, cd);
60 | return;
61 | }
62 | classes.add(cd);
63 | }
64 |
65 | public void add(PackageDescr pd) {
66 | for (int i = 0; i < subpackages.size(); i++)
67 | if (((PackageDescr) subpackages.get(i)).getQualifiedName().compareTo(pd.getQualifiedName()) > 0) {
68 | subpackages.add(i, pd);
69 | return;
70 | }
71 |
72 | subpackages.add(pd);
73 | }
74 |
75 |
76 | public void addAll(List list) {
77 | classes.addAll(list);
78 | }
79 |
80 | public void clear() {
81 | this.classes.clear();
82 | }
83 |
84 | public List getDeclaredClasses() {
85 | return classes;
86 | }
87 |
88 | public List getDeclaredPackages() {
89 | return subpackages;
90 | }
91 |
92 | public String toString() {
93 | return fqname;
94 | }
95 |
96 | public boolean equals(Object arg) {
97 | return arg instanceof PackageDescr && this.fqname.equals(((PackageDescr) arg).getQualifiedName());
98 | }
99 |
100 | public int hashCode() {
101 | int hash = 7;
102 | hash = 59 * hash + (this.fqname != null ? this.fqname.hashCode() : 0);
103 | return hash;
104 | }
105 |
106 | public boolean isCompatible(MemberDescription m) {
107 | return this.equals(m);
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/sigfile/F41Parser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: F41Parser.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.sigfile;
29 |
30 | import com.sun.tdk.signaturetest.model.ClassDescription;
31 | import com.sun.tdk.signaturetest.model.MemberDescription;
32 | import com.sun.tdk.signaturetest.model.MemberType;
33 | import java.util.Set;
34 |
35 | /**
36 | * Parse string representation used in sigfile v4.1 and create corresponding
37 | * member object
38 | *
39 | * @author Mikhail Ershov
40 | */
41 | class F41Parser extends F40Parser {
42 |
43 | protected boolean parseFutureSpecific(String str, ClassDescription cl) {
44 | if (str.startsWith(F41Format.X_FIELDS)) {
45 | Set internalFields = parseInternals(str);
46 | cl.setXFields(internalFields);
47 | return true;
48 | }
49 | if (str.startsWith(F41Format.X_CLASSES)) {
50 | Set internalClasses = parseInternals(str);
51 | cl.setXClasses(internalClasses);
52 | return true;
53 | }
54 | return false;
55 | }
56 |
57 | protected String convertFutureSpecific(String str, ClassDescription classDescription) {
58 | if (str.startsWith(MemberType.CONSTRUCTOR.toString() /* toString returns prefix here */)) {
59 | // is it "old-style" ?
60 | if (str.indexOf("init(") == -1) {
61 | String name = '.' + classDescription.getName() +'(';
62 | int i = str.indexOf(name);
63 | // String.replace can not be used here - it appeared in 1.5
64 | if (i >=0) {
65 | String first = str.substring(0, i);
66 | String last = str.substring(i + name.length());
67 | str = first + ".init(" + last;
68 | }
69 | }
70 | }
71 | return str;
72 | }
73 |
74 | protected ClassDescription processClassDescription(String classDefinition) {
75 | ClassDescription classDescription = (ClassDescription) parse(classDefinition);
76 | classDescription.setupClassName(classDescription.getQualifiedName(),
77 | MemberDescription.NO_DECLARING_CLASS);
78 | return classDescription;
79 | }
80 |
81 | protected void processOuter(ClassDescription classDescription, String str) {
82 | classDescription.setDeclaringClass(parseOuter(str));
83 | classDescription.setupClassName(classDescription.getQualifiedName(),
84 | classDescription.getDeclaringClassName());
85 | }
86 |
87 | protected String parseOuter(String str) {
88 | return str.substring(ClassDescription.OUTER_PREFIX.length()+1);
89 | }
90 |
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/src/test/resources/org/netbeans/apitest/PropertySupport.template:
--------------------------------------------------------------------------------
1 | package org.openide.nodes;
2 |
3 | import java.beans.Beans;
4 | import java.beans.PropertyEditor;
5 | import java.lang.reflect.InvocationTargetException;
6 | import java.lang.reflect.Method;
7 | import java.lang.reflect.Modifier;
8 |
9 | public abstract class PropertySupport extends Node.Property {
10 | /** flag whether the property is readable */
11 | private boolean canR;
12 |
13 | /** flag whether the property is writable */
14 | private boolean canW;
15 |
16 | /** Constructs a new support.
17 | * @param name the name of the property
18 | * @param type the class type of the property
19 | * @param displayName the display name of the property
20 | * @param canR whether the property is readable
21 | * @param canW whether the property is writable
22 | */
23 | public PropertySupport(
24 | String name, Class type, String displayName, String shortDescription, boolean canR, boolean canW
25 | ) {
26 | super(type);
27 | this.setName(name);
28 | setDisplayName(displayName);
29 | setShortDescription(shortDescription);
30 | this.canR = canR;
31 | this.canW = canW;
32 | }
33 |
34 | /* Can read the value of the property.
35 | * Returns the value passed into constructor.
36 | * @return true if the read of the value is supported
37 | */
38 | public boolean canRead() {
39 | return canR;
40 | }
41 |
42 | /* Can write the value of the property.
43 | * Returns the value passed into constructor.
44 | * @return true if the read of the value is supported
45 | */
46 | public boolean canWrite() {
47 | return canW;
48 | }
49 |
50 | /**
51 | * Like {@link Class#cast} but handles primitive types.
52 | * See JDK #6456930.
53 | */
54 | @SuppressWarnings("unchecked")
55 | static T cast(Class c, Object o) {
56 | if (c.isPrimitive()) {
57 | // Could try to actually type-check it, but never mind.
58 | return (T) o;
59 | } else {
60 | return c.cast(o);
61 | }
62 | }
63 |
64 | /** Support for the name property of a node. Delegates {@link #setValue} and {@link #getValue}
65 | * to {@link Node#setName} and {@link Node#getName}.
66 | */
67 | public static final class Name extends PropertySupport {
68 | /** The node to which we delegate the work. */
69 | private final Node node;
70 |
71 | /** Create the name property for a node with the standard name and hint.
72 | * @param node the node
73 | */
74 | public Name(final Node node) {
75 | this(
76 | node, "CTL_StandardName",
77 | "CTL_StandardHint"
78 | );
79 | }
80 |
81 | /** Create the name property for a node.
82 | * @param node the node
83 | * @param propName name of the "name" property
84 | * @param hint hint message for the "name" property
85 | */
86 | public Name(final Node node, final String propName, final String hint) {
87 | super("name", String.class, propName, hint, true, true);
88 | this.node = node;
89 | }
90 |
91 | /* Getter for the value. Delegates to Node.getName().
92 | * @return the name
93 | */
94 | public String getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
95 | return node.getName();
96 | }
97 |
98 | /* Setter for the value. Delegates to Node.setName().
99 | * @param val new name
100 | */
101 | public void setValue(String val)
102 | throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
103 | Object oldName = node.getName();
104 | node.setName(val);
105 | }
106 | }
107 | // end of Name inner class
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/apicover/i18n.properties:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 | #
5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 | #
8 | # This code is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License version 2 only, as
10 | # published by the Free Software Foundation. Sun designates this
11 | # particular file as subject to the "Classpath" exception as provided
12 | # by Sun in the LICENSE file that accompanied this code.
13 | #
14 | # This code is distributed in the hope that it will be useful, but WITHOUT
15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 | # version 2 for more details (a copy is included in the LICENSE file that
18 | # accompanied this code).
19 | #
20 | # You should have received a copy of the GNU General Public License version
21 | # 2 along with this work; if not, write to the Free Software Foundation,
22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
25 | # CA 95054 USA or visit www.sun.com if you need additional information or
26 | # have any questions.
27 | #
28 |
29 | Main.error.arg.conflict=Option {0} conflict with {1}
30 | Main.error.arg.invalid=Invalid value for option: {0}
31 | Main.error.arg.legacy=Option <{0}> is not supported.
32 | Main.error.check=Unexpected exception during check {0}
33 | Main.error.sec.newclasses=The security constraint does not allow tracking class path for tracking of the added new classes.
34 | #Main.error.classpath.unspec=TS classpath not specified or incorrect.
35 | Main.error.sigfile.invalid=Invalid signature file: {0}
36 |
37 | Main.warning.ts.empty={0}(No TS classes found)
38 | Main.warning.class.invalid=Invalid class file: {0}
39 |
40 | Main.usage.start=Available options are:
41 | Main.usage.ts={0} specifies where to find TS classes
42 | Main.usage.tsInclude={0} includes classes from the specified package (recursive)
43 | Main.usage.tsIncludeW={0} includes classes from the specified package (without subpackages)
44 | Main.usage.tsExclude={0} exclude sclasses from the specified package (recursive)
45 | Main.usage.api={0} specifies where to find signature file of API
46 | Main.usage.apiInclude={0} includes classes from the specified package (recursive)
47 | Main.usage.apiIncludeW={0} includes classes from the specified package (without subpackages)
48 | Main.usage.apiExclude={0} excludes classes from the specified package (recursive)
49 | Main.usage.excludeList={0} specifies exclude list file
50 | Main.usage.excludeInterfaces={0} excludes all interfaces
51 | Main.usage.excludeAbstractClasses={0} excludes all abstract classes
52 | Main.usage.excludeAbstractMethods={0} excludes all abstract methods
53 | Main.usage.excludeFields={0} excludes all fields
54 | Main.usage.includeConstantFields={0} includes all final constant fields
55 | Main.usage.mode={0} specifies mode of coverage calculation ''w'' or ''r''
56 | Main.usage.detail={0} specifies level of report refining 0..4
57 | Main.usage.format={0} specifies report format (plain/xml)
58 | Main.usage.report={0} specifies where to place generated report file
59 | Main.usage.debug={0} enable debug mode
60 | Main.usage.help={0} print this text
61 | Main.usage.version={0} print version
62 | Main.usage.end=All options are case-insensitive.
63 |
64 | ReportPlain.report.Coverage=Coverage Report
65 | ReportPlain.report.Package=Package
66 | ReportPlain.report.classes=classes
67 | ReportPlain.report.Class=Class
68 | ReportPlain.report.members=members
69 | ReportPlain.report.tested=tested
70 | ReportPlain.report.Member=Member
71 | ReportPlain.report.Overall=Overall coverage
72 | ReportPlain.report.Legend=Legend
73 | ReportPlain.report.covered=covered member
74 | ReportPlain.report.uncovered=uncovered member
75 | ReportPlain.report.Configuration=Configuration
76 |
77 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/util/LogFormatter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 |
29 | package com.sun.tdk.signaturetest.util;
30 |
31 | import java.io.PrintWriter;
32 | import java.io.StringWriter;
33 | import java.util.logging.Formatter;
34 | import java.util.logging.LogRecord;
35 |
36 | /**
37 | * This is formatter for java.util.logging's ConsoleHandler
38 | * prints file name and line number where log occuresd
39 | * Can be turned on in different ways, for example via property file:
40 | * -Djava.util.logging.config.file=/home/ersh/wrk/st/trunk_prj/logging.properties
41 | * where logging.properties contains
42 | * --------------------------------
43 | * handlers= java.util.logging.ConsoleHandler
44 | * java.util.logging.ConsoleHandler.formatter = com.sun.tdk.signaturetest.util.LogFormatter
45 | * --------------------------------
46 | *
47 | * @author Mikhail Ershov
48 | */
49 | public class LogFormatter extends Formatter {
50 | public String format(LogRecord record) {
51 | StringBuffer sb = new StringBuffer();
52 | sb.append(record.getLevel().getLocalizedName());
53 | sb.append(':');
54 | String s = formatMessage(record);
55 | if (s.indexOf("append") >= 0)
56 | sb.append(s);
57 | else
58 | return "";
59 |
60 | if (record.getThrown() != null) {
61 | try {
62 | StringWriter sw = new StringWriter();
63 | PrintWriter pw = new PrintWriter(sw);
64 | record.getThrown().printStackTrace(pw);
65 | pw.close();
66 | sb.append(sw.toString());
67 | } catch (Exception ex) {
68 | }
69 | }
70 | StackTraceElement se = findCaller();
71 | if (se != null) {
72 | sb.append(" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ");
73 | sb.append(se.toString());
74 | }
75 | sb.append('\n');
76 | return sb.toString();
77 | }
78 |
79 |
80 | private StackTraceElement findCaller() {
81 | StackTraceElement stack[] = (new Throwable()).getStackTrace();
82 | int ix = 0;
83 | while (ix < stack.length) {
84 | StackTraceElement frame = stack[ix];
85 | String cname = frame.getClassName();
86 | if (cname.equals("java.util.logging.Logger")) {
87 | break;
88 | }
89 | ix++;
90 | }
91 | while (ix < stack.length) {
92 | StackTraceElement frame = stack[ix];
93 | String cname = frame.getClassName();
94 | if (!cname.equals("java.util.logging.Logger")) {
95 | return frame;
96 | }
97 | ix++;
98 | }
99 | return null;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/Result.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: Result.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest;
29 |
30 | import com.sun.tdk.signaturetest.util.I18NResourceBundle;
31 |
32 | /**
33 | * This is utility class for Setup, SignatureTest and Merge.
34 | *
35 | * @author Serguei Ivashin
36 | */
37 | public class Result {
38 |
39 | static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Result.class);
40 |
41 | // Name of system property, see exit method
42 | public final static String NO_EXIT = "SigTest.NO_EXIT";
43 |
44 |
45 | private int type = NOT_RUN;
46 | private String reason;
47 |
48 | private static final int PASSED = 0;
49 | private static final int FAILED = 1;
50 | private static final int ERROR = 2;
51 | private static final int NOT_RUN = 3;
52 | private static final String[] texts = {i18n.getString("Result.code.passed"),
53 | i18n.getString("Result.code.failed"), i18n.getString("Result.code.error"),
54 | i18n.getString("Result.code.notrun")};
55 | private static final int[] exitCodes = {95, 97, 98, 99};
56 |
57 |
58 | public String toString() {
59 | String invargs[] = {texts[type], (reason == null ? "" : reason)};
60 | return i18n.getString("Result.message.status", invargs);
61 | }
62 |
63 |
64 | protected boolean passed() {
65 | type = PASSED;
66 | reason = null;
67 | return true;
68 | }
69 |
70 |
71 | public boolean passed(String s) {
72 | type = PASSED;
73 | reason = s;
74 | return true;
75 | }
76 |
77 |
78 | public boolean failed(String s) {
79 | type = FAILED;
80 | reason = s;
81 | return false;
82 | }
83 |
84 |
85 | public boolean error(String s) {
86 | type = ERROR;
87 | reason = s;
88 | return false;
89 | }
90 |
91 |
92 | public boolean notrun(String s) {
93 | type = NOT_RUN;
94 | reason = s;
95 | return true;
96 | }
97 |
98 | public boolean isPassed() {
99 | return type == PASSED;
100 | }
101 |
102 | protected String getReason() {
103 | return reason;
104 | }
105 |
106 | protected boolean exit() {
107 | if (System.err != null) {
108 | System.err.println(toString());
109 | System.err.flush();
110 | }
111 | // for unit-tests and mass runs
112 |
113 | // Don't change this to if(Boolean.parseBoolean(System.getProperty(NO_EXIT))) {
114 | // because Boolean.parseBoolean is since 1.5
115 | if(new Boolean(System.getProperty(NO_EXIT)).booleanValue()) {
116 | return isPassed();
117 | } else {
118 | System.exit(exitCodes[type]);
119 | return false; // never happens
120 | }
121 |
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/plugin/PluginAPI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.plugin;
29 |
30 | import com.sun.tdk.signaturetest.core.ClassDescriptionLoader;
31 | import com.sun.tdk.signaturetest.sigfile.Format;
32 |
33 | /**
34 | * @author Roman Makarchuk
35 | */
36 | public interface PluginAPI {
37 |
38 | // Injections that have default implementation
39 | static final InjectionPoint IS_CLASS_ACCESSIBLE = new InjectionPoint(true, false);
40 | static final InjectionPoint AFTER_BUILD_MEMBERS = new InjectionPoint(false, true);
41 |
42 | static final InjectionPoint ON_CLASS_LOAD = new InjectionPoint(false, true);
43 |
44 | // Filter and Transformer
45 | static final InjectionPoint BEFORE_TEST = new InjectionPoint(false, true);
46 |
47 | // Injections only for transformers
48 | static final InjectionPoint AFTER_CLASS_CORRECTOR = new InjectionPoint(false, true);
49 | static final InjectionPoint CLASS_CORRECTOR = new InjectionPoint(false, true);
50 |
51 | Context getContext();
52 |
53 | Filter getFilter(InjectionPoint injectionPoint);
54 | void setFilter(InjectionPoint injectionPoint, Filter filter);
55 |
56 | Transformer getTransformer(InjectionPoint injectionPoint);
57 | void setTransformer(InjectionPoint injectionPoint, Transformer transformer);
58 |
59 | // add new format to read/write signature files
60 | void addFormat(Format format, boolean useByDefault);
61 |
62 | // set format to read/write signature files
63 | void setFormat(Format format);
64 |
65 | // set own classDesription loader
66 | void setClassDescrLoader(ClassDescriptionLoader loader);
67 |
68 | class InjectionPoint {
69 | boolean filterAccepted; // transform otherwise
70 | boolean transformAccepted;
71 |
72 | Filter filter = null;
73 | Transformer transformer = null;
74 |
75 | private InjectionPoint(boolean filterAccepted, boolean transformAccepted) {
76 | this.filterAccepted = filterAccepted;
77 | this.transformAccepted = transformAccepted;
78 | }
79 |
80 | public Filter getFilter() {
81 | return filter;
82 | }
83 |
84 | public void setFilter(Filter filter) {
85 | if (!filterAccepted)
86 | throw new UnsupportedOperationException();
87 | this.filter = filter;
88 | }
89 |
90 | public Transformer getTransformer() {
91 | return transformer;
92 | }
93 |
94 | public void setTransformer(Transformer transformer) {
95 | if (!transformAccepted)
96 | throw new UnsupportedOperationException();
97 | this.transformer = transformer;
98 | }
99 | }
100 | }
101 |
102 |
103 | /*
104 | Mode:
105 |
106 | setup
107 | test source
108 | test binary
109 |
110 | */
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/classpath/JarFileEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: JarFileEntry.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.classpath;
29 |
30 | import com.sun.tdk.signaturetest.SigTest;
31 |
32 | import com.sun.tdk.signaturetest.model.ExoticCharTools;
33 | import java.io.IOException;
34 | import java.io.InputStream;
35 | import java.util.Enumeration;
36 | import java.util.LinkedHashSet;
37 | import java.util.jar.JarEntry;
38 | import java.util.jar.JarFile;
39 |
40 | /**
41 | * @author Maxim Sokolnikov
42 | * @author Roman Makarchuk
43 | */
44 | class JarFileEntry extends ClasspathEntry {
45 |
46 | /**
47 | * Specified jar file. *
48 | */
49 | private JarFile jarfile;
50 |
51 |
52 | public JarFileEntry(ClasspathEntry previous, String jarfile) throws IOException {
53 | super(previous);
54 | init(jarfile);
55 | }
56 |
57 |
58 | public void init(String jarfile) throws IOException {
59 | this.jarfile = new JarFile(jarfile);
60 |
61 | Enumeration entries = this.jarfile.entries();
62 | classes = new LinkedHashSet();
63 | while (entries.hasMoreElements()) {
64 | String name = ((JarEntry) entries.nextElement()).getName();
65 | if (name.endsWith(JAVA_CLASSFILE_EXTENSION)) {
66 | name = name.substring(0, name.length() - JAVA_CLASSFILE_EXTENSION_LEN).replace('/', '.');
67 | if (previousEntry==null || !previousEntry.contains(name))
68 | classes.add(name.intern());
69 | }
70 | }
71 | currentPosition = classes.iterator();
72 | }
73 |
74 |
75 | /**
76 | * Closes zip/jar file.
77 | */
78 | public void close() {
79 | if (jarfile != null) {
80 | try {
81 | jarfile.close();
82 | }
83 | catch (IOException e) {
84 | if (SigTest.debug)
85 | e.printStackTrace();
86 | }
87 | jarfile = null;
88 | classes = null;
89 | }
90 | }
91 |
92 | /**
93 | * Returns InputStream providing bytecode for the required class,
94 | * if that class could be found by the given qualified name in JarFileEntry.
95 | *
96 | * @param name Qualified name of the class requested.
97 | * @throws ClassNotFoundException if the class was not found inside this JarFileEntry.
98 | */
99 | public InputStream findClass(String name) throws IOException, ClassNotFoundException {
100 |
101 | name = ExoticCharTools.decodeExotic(name);
102 |
103 | JarEntry jarEntry = jarfile.getJarEntry(name.replace('.', '/') + JAVA_CLASSFILE_EXTENSION);
104 | if (jarEntry == null)
105 | throw new ClassNotFoundException(name);
106 |
107 | return jarfile.getInputStream(jarEntry);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/exclude/ExcludeList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: ExcludeList.java 4504 2008-03-13 16:12:22Z sg215604 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.exclude;
29 |
30 | import com.sun.tdk.signaturetest.core.Exclude;
31 | import com.sun.tdk.signaturetest.core.ExcludeException;
32 | import com.sun.tdk.signaturetest.model.ClassDescription;
33 | import com.sun.tdk.signaturetest.model.MemberDescription;
34 |
35 | import java.util.*;
36 | import java.util.regex.Matcher;
37 | import java.util.regex.Pattern;
38 | import java.util.regex.PatternSyntaxException;
39 |
40 |
41 | /**
42 | * This is a sample realization of Exclude extension.
43 | *
44 | * @author Leonid Mesnik
45 | */
46 | public class ExcludeList implements Exclude {
47 | private List excludeList;
48 |
49 | public ExcludeList() {
50 | excludeList = new ArrayList();
51 | }
52 |
53 |
54 | /* (non-Javadoc)
55 | * @see com.sun.tdk.exclude.Exclude#addSignature(java.lang.String)
56 | */
57 | public void addSignature(String name) {
58 | String regpack1 = name.replaceAll("(\\.|\\(|\\)|\\{|\\}|\\[|\\]|\\%|\\$)","\\\\$1");
59 | String regpack = regpack1.replaceAll("\\\\\\\\", "");
60 | try {
61 | excludeList.add(Pattern.compile(regpack));
62 | } catch (PatternSyntaxException e) {
63 | System.err.println("Error in -ExcludeSig: " + e.getMessage());
64 | }
65 | }
66 |
67 | /* (non-Javadoc)
68 | * @see com.sun.tdk.exclude.Exclude#excluded(java.lang.String)
69 | */
70 | public void check(ClassDescription testedClass, MemberDescription name) throws ExcludeException {
71 | String signature = name.getQualifiedName().replaceAll("<[^<>]+>", "");
72 | if (name.isMethod() || name.isConstructor()) {
73 | signature += '(';
74 | signature += name.getArgs().replaceAll("<[^<>]+>", "");
75 | signature += ')';
76 | }
77 | for (Iterator i = excludeList.iterator(); i.hasNext();) {
78 | Pattern p = (Pattern) i.next();
79 | Matcher m = p.matcher(signature);
80 | if (m.matches()) {
81 | throw new ExcludeException(p.pattern());
82 | }
83 | }
84 | }
85 |
86 |
87 | public String[] parseParameters(String[] args) {
88 | Set rest = new HashSet();
89 | List parameters = new ArrayList(Arrays.asList(args));
90 | Iterator i = parameters.iterator();
91 | while (i.hasNext()) {
92 | String parameter = (String) i.next();
93 | if (parameter.equalsIgnoreCase("-excludesig")) {
94 | rest.add(parameter);
95 | parameter = (String) i.next();
96 | addSignature(parameter);
97 | rest.add(parameter);
98 | }
99 | }
100 | parameters.removeAll(rest);
101 | return (String[]) parameters.toArray(new String[0]);
102 | }
103 |
104 | public String report() {
105 | return "finished";
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/src/test/java/org/netbeans/apitest/VersionCheckSigtestTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Sun designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Sun in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 | * CA 95054 USA or visit www.sun.com if you need additional information or
23 | * have any questions.
24 | */
25 | package org.netbeans.apitest;
26 |
27 | import java.io.File;
28 | import java.util.ArrayList;
29 | import java.util.Arrays;
30 | import java.util.List;
31 | import junit.framework.Test;
32 | import org.netbeans.junit.NbTestSuite;
33 |
34 | /** Runs all the tests as for compatibility check, but in case we check
35 | * that nothing changed, it does "strictcheck" e.g. the full check for
36 | * mutual compatibility.
37 | *
38 | * @author Jaroslav Tulach
39 | */
40 | public class VersionCheckSigtestTest extends CheckNewSigtestTest {
41 | public VersionCheckSigtestTest(String s) {
42 | super(s);
43 | }
44 |
45 | public static Test suite() {
46 | Test t = null;
47 | // t = new VersionCheckSigtestTest("testConvertingNonFinalClassToAbstract");
48 | return t != null ? t : new NbTestSuite(VersionCheckSigtestTest.class);
49 | }
50 |
51 | @Override
52 | protected void compareAPIs(int slotFirst, int slotSecond, String... additionalArgs) throws Exception {
53 | File d1 = new File(getWorkDir(), "dir" + slotFirst);
54 | File d2 = new File(getWorkDir(), "dir" + slotSecond);
55 |
56 | File build = new File(getWorkDir(), "build.xml");
57 | extractResource("build.xml", build);
58 |
59 | List args = new ArrayList();
60 | args.addAll(Arrays.asList(additionalArgs));
61 | args.add("with-version");
62 | args.add("-Ddir1=" + d1);
63 | args.add("-Ddir2=" + d2);
64 |
65 | // these three lines will skip the check
66 | args.add("-Dv1=1.0");
67 | if (
68 | getName().equals("testMissingFieldInAbstractClassIsDetected") ||
69 | getName().equals("testMissingStaticFieldDetected") ||
70 | getName().equals("testMissingConstructorInAbstractClassIsDetected") ||
71 | getName().equals("testConvertingNonFinalClassToAbstract") ||
72 | getName().equals("testAddInterfaceMethod")
73 | ) {
74 | // do the test of signatures for these special tests
75 | args.add("-Dv2=1.0");
76 | } else {
77 | args.add("-Dv2=2.0");
78 | }
79 | args.add("-Dcheck.type=versioncheck");
80 |
81 | ExecuteUtils.execute(build, args.toArray(new String[0]));
82 | }
83 |
84 | @Override
85 | protected final void checkAPIsEqual(String... additionalArgs) throws Exception {
86 | File d1 = new File(getWorkDir(), "dir1");
87 |
88 | File build = new File(getWorkDir(), "build.xml");
89 | extractResource("build.xml", build);
90 |
91 | List args = new ArrayList();
92 | args.addAll(Arrays.asList(additionalArgs));
93 | args.add("with-version");
94 | args.add("-Ddir1=" + d1);
95 | args.add("-Dv1=1.0");
96 | args.add("-Ddir2=" + d1);
97 | args.add("-Dv2=1.0");
98 | args.add("-Dcheck.type=versioncheck");
99 | ExecuteUtils.execute(build, args.toArray(new String[0]));
100 | }
101 |
102 | }
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/core/PackageGroup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.core;
29 |
30 | import java.util.ArrayList;
31 | import java.util.Iterator;
32 | import java.util.List;
33 |
34 | /**
35 | * PackageGroup is intended to maintain a list of packages
36 | * names. It provides a tool to check if given class belongs to
37 | * some of the packages listed by PackageGroup, or if that
38 | * class belongs to some subpackage of some of the listed packages.
39 | *
40 | * @author Maxim Sokolnikov
41 | * @author Serguei Ivashin
42 | */
43 | public class PackageGroup {
44 | /**
45 | * For every package listed in the group filed,
46 | * indicate if its subpackages are implicitly implied.
47 | *
48 | * @see #group
49 | */
50 | private boolean isSubpackagesUses = true;
51 |
52 | /**
53 | * List of strings intended to contain names of packages.
54 | * If the field isSubpackagesUses is true,
55 | * all subpackages names are implicitly implied for each package
56 | * name listed here.
57 | *
58 | * @see #isSubpackagesUses
59 | */
60 | private List group;
61 |
62 | /**
63 | * Create empty list of packages, and decide if subpackages
64 | * should be implied.
65 | */
66 | public PackageGroup(boolean isSubpackagesUses) {
67 | this.isSubpackagesUses = isSubpackagesUses;
68 | group = new ArrayList();
69 | }
70 |
71 | public boolean isEmpty() {
72 | return group.isEmpty();
73 | }
74 |
75 | public String toString() {
76 | return group.toString();
77 | }
78 |
79 | /**
80 | * Add some package name to this group.
81 | */
82 | public void addPackage(String packageName) {
83 | group.add(packageName);
84 | }
85 |
86 | public void addPackages(String[] packageNames) {
87 | for (int i = 0; i < packageNames.length; ++i)
88 | group.add(packageNames[i]);
89 | }
90 |
91 |
92 | /**
93 | * Check if the given class name belongs to some of
94 | * the packages listed by this PackageGroup.
95 | * If isSubpackagesUsed policy is set, also check if
96 | * that class belongs to some subpackage of some of the packages
97 | * listed here.
98 | */
99 | public boolean checkName(String className) {
100 | for (Iterator i = group.iterator(); i.hasNext();) {
101 | String pack = (String) i.next();
102 | if ((className.startsWith(getPackageName(pack)) &&
103 | ((className.lastIndexOf('.') <= pack.length()) || isSubpackagesUses)) || className.equals(pack))
104 | return true;
105 | }
106 | return false;
107 | }
108 |
109 | /**
110 | * Terminate the given package name with the dot symbol,
111 | * if the name is nonempty.
112 | */
113 | private static String getPackageName(String name) {
114 | return name + ((name.endsWith(".") || name.equals("")) ? "" : ".");
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/resources/com/sun/tdk/signaturetest/errors/i18n.properties:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 | #
5 | # Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 | #
8 | # This code is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License version 2 only, as
10 | # published by the Free Software Foundation. Sun designates this
11 | # particular file as subject to the "Classpath" exception as provided
12 | # by Sun in the LICENSE file that accompanied this code.
13 | #
14 | # This code is distributed in the hope that it will be useful, but WITHOUT
15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 | # version 2 for more details (a copy is included in the LICENSE file that
18 | # accompanied this code).
19 | #
20 | # You should have received a copy of the GNU General Public License version
21 | # 2 along with this work; if not, write to the Free Software Foundation,
22 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
25 | # CA 95054 USA or visit www.sun.com if you need additional information or
26 | # have any questions.
27 | #
28 |
29 | ErrorFormatter.error.missing.classes=Missing Classes
30 | ErrorFormatter.error.missing.nested.classes=Missing Nested Classes
31 | ErrorFormatter.error.missing.superclasses=Missing Superclasses or Superinterfaces
32 | ErrorFormatter.error.missing.field=Missing Fields
33 | ErrorFormatter.error.missing.methods=Missing Methods
34 | ErrorFormatter.error.missing.construct=Missing Constructors
35 | ErrorFormatter.error.added.classes=Added Classes
36 | ErrorFormatter.error.added.nested.classes=Added Nested Classes
37 | ErrorFormatter.error.added.superclasses=Added Superclasses or Superinterfaces
38 | ErrorFormatter.error.added.field=Added Fields
39 | ErrorFormatter.error.added.construct=Added Constructors
40 | ErrorFormatter.error.added.methods=Added Methods
41 | ErrorFormatter.error.linkerror=LinkageError does not allow to track definition in
42 | ErrorFormatter.error.addedanno.defn=Added Annotations
43 | ErrorFormatter.error.missinganno.defn=Missed Annotations
44 | ErrorFormatter.error.changedsuperclasses.topol=Topology of Interface Inheritance
45 | ErrorFormatter.error.unknown=Unknown error
46 |
47 | SortedErrorFormatter.error.affected=--- affected {0}
48 | SortedErrorFormatter.error.dupmesg=duplicate messages suppressed: {0}
49 |
50 | HumanErrorFormatter.error.change.clss.or.memb=Changed
51 |
52 | BCProcessor.error.1_1 = "W1.1 - API type added"
53 | BCProcessor.error.1_2 = "E1.2 - API type removed"
54 | BCProcessor.error.1_3 = "E1.3 - Narrowing type or member visibility"
55 | BCProcessor.error.2_1 = "E2.1 - Interface method added"
56 | BCProcessor.error.2_2 = "E2.2 - Interface field added"
57 | BCProcessor.error.2_3 = "W2.3 - Adding interfaces with constants "
58 | BCProcessor.error.2_4 = "E2.4 - Contracting superinterface set (direct or inherited) "
59 | BCProcessor.error.2_5 = "E2.5 - Adding member without default value to annotation type"
60 | BCProcessor.error.2_7 = "E2.7 - Removing member from annotation type"
61 | BCProcessor.error.2_8 = "E2.8 - Removing default value from member of annotation type"
62 | BCProcessor.error.3_1 = "E3.1 - Changing method signature and/or return type"
63 | BCProcessor.error.3_3 = "E3.3 - Changing parameter from arity T... to array type T[]"
64 | BCProcessor.error.3_4 = "E3.4 - Changing normalized throw list"
65 | BCProcessor.error.3_6 = "W3.6 - Increase access, from protected to public if the class is subclassable"
66 | BCProcessor.error.3_8 = "E3.8 - Changing method from non-abstract to abstract"
67 | BCProcessor.error.3_10 = "E3.10 - Changing method from non-final to final"
68 | BCProcessor.error.3_11 = "E3.11 - Changing method from static to non-static"
69 | BCProcessor.error.3_12 = "E3.12 - Changing method from non-static to static"
70 | BCProcessor.error.4_1 = "E4.1 - Changing field type"
71 | BCProcessor.error.4_2 = "W4.2 - Changing field constant value"
72 | BCProcessor.error.4_6 = "E4.6 - Changing field from non-final to final"
73 | BCProcessor.error.4_7 = "E4.7 - Changing field from static to non-static"
74 | BCProcessor.error.4_8 = "E4.8 - Changing field from non-static to static"
75 | BCProcessor.error.5_1_2= "W5.1.2 - Adding methods"
76 | BCProcessor.error.5_2 = "E5.2 - Adding abstract methods"
77 | BCProcessor.error.5_3 = "E5.3 - Adding static methods"
78 | BCProcessor.error.5_4 = "E5.4 - Removing constructor"
79 | BCProcessor.error.5_6 = "W5.6 - Adding fields"
80 | BCProcessor.error.5_12 = "E5.12 - Changing class from non-abstract to abstract"
81 | BCProcessor.error.5_14 = "E5.14 - Changing class from non-final to final"
82 |
83 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/model/MemberCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: MemberCollection.java 4516 2008-03-17 18:48:27Z eg216457 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.model;
29 |
30 | import java.util.Collection;
31 | import java.util.HashSet;
32 | import java.util.Iterator;
33 | import java.util.Set;
34 |
35 | /**
36 | * @author Maxim Sokolnikov
37 | * @author Roman Makarchuk
38 | */
39 | public class MemberCollection {
40 |
41 | private Set members;
42 |
43 | public MemberCollection() {
44 | members = new HashSet();
45 | }
46 |
47 | /**
48 | * Add the given member to this member collection.
49 | * If a member with the the same "key" already exists in the collection,
50 | * the new member will override it.
51 | *
52 | * @param member New member to add to the collection.
53 | */
54 |
55 | public void addMember(MemberDescription member) {
56 | if (MemberType.CLASS==member.getMemberType())
57 | throw new IllegalArgumentException("Instances of ClassDescription are not allowed here!");
58 | members.add(member);
59 | }
60 |
61 | public void updateMember(MemberDescription member) {
62 | if (MemberType.CLASS==member.getMemberType())
63 | throw new IllegalArgumentException("Instances of ClassDescription are not allowed here!");
64 | members.remove(member);
65 | members.add(member);
66 | }
67 |
68 |
69 | public Collection getAllMembers() {
70 | return members;
71 | }
72 |
73 | public boolean contains(MemberDescription newMember) {
74 | return members.contains(newMember);
75 | }
76 |
77 | public Iterator iterator() {
78 | return members.iterator();
79 | }
80 |
81 | public void changeMember(MemberDescription oldMember, MemberDescription newMember) {
82 | if (MemberType.CLASS==newMember.getMemberType())
83 | throw new IllegalArgumentException("Instances of ClassDescription are not allowed here!");
84 | if (!contains(oldMember))
85 | throw new IllegalArgumentException("Member " + oldMember + " not found!");
86 | members.remove(oldMember);
87 | members.add(newMember);
88 | }
89 |
90 |
91 | // TODO (Roman Makarchuk) weak performance!
92 | public MemberDescription find(MemberDescription mr) {
93 | for (Iterator e = members.iterator(); e.hasNext();) {
94 | MemberDescription member = (MemberDescription) e.next();
95 | if (member.equals(mr))
96 | return member;
97 | }
98 | return null;
99 | }
100 |
101 | public MemberDescription findSimilar(MemberDescription mr) {
102 | for (Iterator e = members.iterator(); e.hasNext();) {
103 | MemberDescription member = (MemberDescription) e.next();
104 | if (member.getType().equals(mr.getType()) && member.getName().equals(mr.getName()))
105 | return member;
106 | }
107 | return null;
108 | }
109 |
110 |
111 | public int getMembersCount(MemberType memberType, String fqname) {
112 | int count = 0;
113 | for (Iterator e = members.iterator(); e.hasNext();) {
114 | MemberDescription member = (MemberDescription) e.next();
115 | if ((memberType == null || memberType==member.getMemberType()) &&
116 | fqname.equals(member.getQualifiedName()))
117 | count++;
118 | }
119 | return count;
120 | }
121 |
122 | }
123 |
124 |
--------------------------------------------------------------------------------
/src/test/java/com/sun/tdk/signaturetest/classpath/ReleaseTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Sun designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Sun in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 | * CA 95054 USA or visit www.sun.com if you need additional information or
23 | * have any questions.
24 | */
25 | package com.sun.tdk.signaturetest.classpath;
26 |
27 | import com.sun.tdk.signaturetest.loaders.BinaryClassDescrLoader;
28 | import com.sun.tdk.signaturetest.model.ClassDescription;
29 | import com.sun.tdk.signaturetest.model.MethodDescr;
30 | import java.util.Arrays;
31 | import java.util.HashSet;
32 | import java.util.Set;
33 | import org.junit.Test;
34 | import static org.junit.Assert.*;
35 |
36 | public class ReleaseTest {
37 |
38 | public ReleaseTest() {
39 | }
40 |
41 | @Test
42 | public void testFindJDK8() throws ClassNotFoundException {
43 | Release jdk8 = Release.find(8);
44 | assertNotNull(jdk8.findClass("java.lang.Object"));
45 | assertNull(jdk8.findClass("java.lang.Module"));
46 |
47 | BinaryClassDescrLoader loader = new BinaryClassDescrLoader(new ClasspathImpl(jdk8, null), 4096);
48 | ClassDescription deprecatedClass = loader.load("java.lang.Deprecated");
49 | assertMethods(deprecatedClass);
50 | }
51 |
52 | @Test
53 | public void testFindJDK9() throws ClassNotFoundException {
54 | Release jdk9 = Release.find(9);
55 | assertNotNull(jdk9.findClass("java.lang.Object"));
56 | assertNotNull(jdk9.findClass("java.lang.Module"));
57 | assertNull(jdk9.findClass("java.lang.Record"));
58 |
59 | BinaryClassDescrLoader loader = new BinaryClassDescrLoader(new ClasspathImpl(jdk9, null), 4096);
60 | ClassDescription deprecatedClass = loader.load("java.lang.Deprecated");
61 | assertMethods(deprecatedClass, "forRemoval", "since");
62 | }
63 |
64 | @Test
65 | public void testFindJDK13() throws ClassNotFoundException {
66 | Release jdk13 = Release.find(13);
67 | assertNotNull(jdk13.findClass("java.lang.Object"));
68 | assertNotNull(jdk13.findClass("java.lang.Module"));
69 | assertNull(jdk13.findClass("java.lang.Record"));
70 |
71 | BinaryClassDescrLoader loader = new BinaryClassDescrLoader(new ClasspathImpl(jdk13, null), 4096);
72 | ClassDescription deprecatedClass = loader.load("java.lang.Deprecated");
73 | assertMethods(deprecatedClass, "forRemoval", "since");
74 | }
75 |
76 | @Test
77 | public void testFindJDK14() {
78 | Release jdk14 = Release.find(14);
79 | assertNotNull(jdk14.findClass("java.lang.Object"));
80 | assertNotNull(jdk14.findClass("java.lang.Module"));
81 | assertNotNull(jdk14.findClass("java.lang.Record"));
82 | }
83 |
84 | @Test
85 | public void testFindJDK15() throws ClassNotFoundException {
86 | Release jdk15 = Release.find(15);
87 | assertNotNull(jdk15.findClass("java.lang.Object"));
88 | assertNotNull(jdk15.findClass("java.lang.Module"));
89 | assertNotNull(jdk15.findClass("java.lang.Record"));
90 | BinaryClassDescrLoader loader = new BinaryClassDescrLoader(new ClasspathImpl(jdk15, null), 4096);
91 | ClassDescription deprecatedClass = loader.load("java.lang.Deprecated");
92 | assertMethods(deprecatedClass, "forRemoval", "since");
93 | }
94 |
95 | private void assertMethods(ClassDescription deprecatedClass, String... names) {
96 | MethodDescr[] arr = deprecatedClass.getDeclaredMethods();
97 | assertEquals("Same number of methods: " + Arrays.toString(arr), names.length, arr.length);
98 |
99 | Set all = new HashSet<>(Arrays.asList(names));
100 | for (int i = 0; i < arr.length; i++) {
101 | MethodDescr m = arr[i];
102 | all.remove(m.getName());
103 | }
104 |
105 | assertEquals("Not found methods " + all, 0, all.size());
106 | }
107 |
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/org/netbeans/apitest/SigtestCompare.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Sun designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Sun in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 | * CA 95054 USA or visit www.sun.com if you need additional information or
23 | * have any questions.
24 | */
25 | package org.netbeans.apitest;
26 |
27 | import java.io.File;
28 | import org.apache.maven.artifact.DefaultArtifact;
29 | import org.apache.maven.artifact.handler.DefaultArtifactHandler;
30 | import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
31 | import org.apache.maven.artifact.resolver.ArtifactResolver;
32 | import org.apache.maven.execution.MavenSession;
33 | import org.apache.maven.plugin.AbstractMojo;
34 | import org.apache.maven.plugin.MojoExecutionException;
35 | import org.apache.maven.plugin.MojoFailureException;
36 | import org.apache.maven.plugins.annotations.Component;
37 | import org.apache.maven.plugins.annotations.LifecyclePhase;
38 | import org.apache.maven.plugins.annotations.Mojo;
39 | import org.apache.maven.plugins.annotations.Parameter;
40 | import org.apache.maven.plugins.annotations.ResolutionScope;
41 | import org.apache.maven.project.MavenProject;
42 |
43 | /** Mojo to compare {@code .class} files with an existing {@code .sigtest}
44 | * file.
45 | *
46 | * @author Jaroslav Tulach
47 | */
48 | @Mojo(
49 | name="compare",
50 | requiresDependencyResolution = ResolutionScope.TEST,
51 | defaultPhase= LifecyclePhase.PACKAGE
52 | )
53 | public final class SigtestCompare extends AbstractMojo {
54 | @Component
55 | private MavenProject prj;
56 | @Component
57 | private MavenSession session;
58 | @Component
59 | private ArtifactResolver artifactResolver;
60 | @Parameter(defaultValue = "${project.build.outputDirectory}")
61 | private File classes;
62 | @Parameter(defaultValue = "${project.build.directory}/${project.build.finalName}.sigfile")
63 | private File sigfile;
64 | @Parameter(defaultValue = "")
65 | private String packages;
66 |
67 | @Parameter(property = "maven.compiler.release")
68 | private String release;
69 | @Parameter(property = "sigtest.releaseVersion")
70 | private String releaseVersion;
71 | @Parameter(defaultValue = "check", property = "sigtest.check")
72 | private String action;
73 | @Parameter(defaultValue = "${project.build.directory}/surefire-reports/sigtest/TEST-${project.build.finalName}.xml")
74 | private File report;
75 | @Parameter(defaultValue = "true", property = "sigtest.fail")
76 | private boolean failOnError;
77 |
78 | public void execute() throws MojoExecutionException, MojoFailureException {
79 | if (packages == null) {
80 | getLog().info("No packages specified, skipping sigtest:compare " + action);
81 | return;
82 | }
83 | if (releaseVersion == null) {
84 | throw new MojoExecutionException("Specify to-directory-with-classfiles-to-test in plugin config section!");
88 | }
89 |
90 | final DefaultArtifact artifact = new DefaultArtifact(prj.getGroupId(), prj.getArtifactId(), releaseVersion, null, "jar", "", new DefaultArtifactHandler("jar"));
91 | try {
92 | artifactResolver.resolve(artifact, session.getProjectBuildingRequest().getRemoteRepositories(), session.getLocalRepository());
93 | } catch (AbstractArtifactResolutionException ex) {
94 | throw new MojoExecutionException("Cannot resolve " + artifact, ex);
95 | }
96 |
97 | SigtestGenerate generate = new SigtestGenerate(prj, artifact.getFile(), sigfile, packages, releaseVersion, release);
98 | generate.execute();
99 |
100 | SigtestCheck check = new SigtestCheck(prj, classes, sigfile, action, packages, report, failOnError);
101 | check.execute();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/sun/tdk/signaturetest/ant/ABase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id: SignatureTest.java 4549 2008-03-24 08:03:34Z me155718 $
3 | *
4 | * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 | *
7 | * This code is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License version 2 only, as
9 | * published by the Free Software Foundation. Sun designates this
10 | * particular file as subject to the "Classpath" exception as provided
11 | * by Sun in the LICENSE file that accompanied this code.
12 | *
13 | * This code is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 | * version 2 for more details (a copy is included in the LICENSE file that
17 | * accompanied this code).
18 | *
19 | * You should have received a copy of the GNU General Public License version
20 | * 2 along with this work; if not, write to the Free Software Foundation,
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 | *
23 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 | * CA 95054 USA or visit www.sun.com if you need additional information or
25 | * have any questions.
26 | */
27 |
28 | package com.sun.tdk.signaturetest.ant;
29 |
30 | import com.sun.tdk.signaturetest.SigTest;
31 | import org.apache.tools.ant.Project;
32 | import org.apache.tools.ant.types.DataType;
33 | import org.apache.tools.ant.types.Path;
34 |
35 | import java.io.File;
36 | import java.util.ArrayList;
37 | import java.util.Iterator;
38 |
39 | /**
40 | * Base class for ant wrappers such as ASetup and ATest
41 | * @author Mikhail Ershov
42 | */
43 | public class ABase extends ASuperBase {
44 |
45 | Path classpath;
46 | ArrayList pac = new ArrayList();
47 | private ArrayList exclude = new ArrayList();
48 | String fileName;
49 | private String apiVersion;
50 |
51 |
52 | void createBaseParameters(ArrayList params) {
53 | params.add(SigTest.FILENAME_OPTION);
54 | params.add(fileName);
55 | params.add(SigTest.CLASSPATH_OPTION);
56 | String [] cp = classpath.list();
57 | StringBuffer cpb = new StringBuffer();
58 | for (int i = 0; i < cp.length; i++) {
59 | cpb.append(cp[i]);
60 | if (i != cp.length - 1) {
61 | cpb.append(File.pathSeparatorChar);
62 | }
63 | }
64 | params.add(cpb.toString());
65 | if (apiVersion != null) {
66 | params.add(SigTest.APIVERSION_OPTION);
67 | params.add(apiVersion);
68 | }
69 | Iterator it = pac.iterator();
70 | while (it.hasNext()) {
71 | params.add(SigTest.PACKAGE_OPTION);
72 | APackage ap = (APackage) it.next();
73 | params.add(ap.value);
74 | }
75 | it = exclude.iterator();
76 | while (it.hasNext()) {
77 | params.add(SigTest.EXCLUDE_OPTION);
78 | AExclude ae = (AExclude) it.next();
79 | params.add(ae.value);
80 | }
81 | }
82 |
83 |
84 | // classpath
85 | public void setClasspath(Path s) {
86 | createClasspath().append(s);
87 | }
88 |
89 | public Path createClasspath() {
90 | return createClasspath(getProject()).createPath();
91 | }
92 |
93 | private Path createClasspath(Project p) {
94 | if (classpath == null) {
95 | classpath = new Path(p);
96 | }
97 | return classpath;
98 | }
99 |
100 |
101 | // exclude
102 | public void setExclude(String s) {
103 | AExclude ae = new AExclude();
104 | exclude.add(ae);
105 | ae.setPackage(s);
106 | }
107 |
108 | public AExclude createExclude() {
109 | AExclude ae = new AExclude();
110 | exclude.add(ae);
111 | return ae;
112 | }
113 |
114 | // package
115 | public void setPackage(String s) {
116 | APackage ae = new APackage();
117 | pac.add(ae);
118 | ae.setName(s);
119 | }
120 |
121 | public APackage createPackage() {
122 | APackage ap = new APackage();
123 | pac.add(ap);
124 | return ap;
125 | }
126 |
127 | // filename
128 | public void setFilename(String s) {
129 | fileName = s;
130 | }
131 |
132 | // APIVersion
133 | public void setApiVersion(String s) {
134 | apiVersion = s;
135 | }
136 |
137 | public static class AExclude extends DataType {
138 | String value;
139 |
140 | public void setPackage(String p) {
141 | value = p;
142 | }
143 |
144 | public void setClass(String p) {
145 | value = p;
146 | }
147 | }
148 |
149 | public static class APackage extends DataType {
150 | String value;
151 |
152 | public void setName(String p) {
153 | value = p;
154 | }
155 | }
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/src/test/resources/org/netbeans/apitest/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------