├── .gitignore ├── .hgignore ├── .hgtags ├── .jcheck └── conf ├── LICENSE ├── README.md ├── THIRD-PARTY ├── build ├── build.properties ├── build.xml ├── check-dependecies.xml ├── filesaver.replace.properties ├── networksaver.replace.properties └── release.properties ├── examples └── tutorial │ ├── Tutorial.html │ ├── doc │ └── document.css │ ├── example1 │ └── static_instr.xml │ ├── example2 │ └── dynamic_instr.xml │ ├── example3 │ └── static_instr_file.xml │ ├── example4 │ └── one_command.xml │ ├── example5 │ └── jcov_ant_tasks.xml │ ├── example6 │ └── jcov_scales.xml │ ├── src │ └── com │ │ └── oracle │ │ └── demoapp │ │ ├── Plane.java │ │ └── figures │ │ ├── Disk.java │ │ ├── Square.java │ │ └── abstractpack │ │ └── Figure.java │ ├── test │ ├── TestDemoApp1.java │ └── TestDemoApp2.java │ ├── tutorial.build.properties │ └── tutorial.build.xml ├── plugins ├── coberturaXML │ ├── README.md │ ├── build │ │ ├── build.properties │ │ └── build.xml │ ├── src │ │ └── openjdk │ │ │ └── codetools │ │ │ └── jcov │ │ │ └── plugin │ │ │ └── coberturaxml │ │ │ ├── CoberturaReportGenerator.java │ │ │ └── CoberturaReportGeneratorSPI.java │ └── tests │ │ ├── tests.properties │ │ ├── tests.xml │ │ └── xml_validation │ │ ├── result.xml │ │ └── test.xml ├── coverage_reports │ ├── .gitignore │ ├── README.md │ ├── build.xml │ ├── src │ │ └── openjdk │ │ │ └── codetools │ │ │ └── jcov │ │ │ └── report │ │ │ ├── Coverage.java │ │ │ ├── CoveredLineRange.java │ │ │ ├── FileCoverage.java │ │ │ ├── FileItems.java │ │ │ ├── FileSet.java │ │ │ ├── LineRange.java │ │ │ ├── commandline │ │ │ ├── CommandLine.java │ │ │ ├── Option.java │ │ │ └── Parameter.java │ │ │ ├── filter │ │ │ ├── GitDiffFilter.java │ │ │ ├── SourceFileFilter.java │ │ │ ├── SourceFilter.java │ │ │ └── UnchangedCodeFilter.java │ │ │ ├── jcov │ │ │ ├── JCovCoverageComparison.java │ │ │ ├── JCovLineCoverage.java │ │ │ └── JCovMethodCoverageComparison.java │ │ │ ├── source │ │ │ ├── ContextFilter.java │ │ │ ├── SourceHierarchy.java │ │ │ ├── SourceHierarchyUnion.java │ │ │ └── SourcePath.java │ │ │ └── view │ │ │ ├── CoverageHierarchy.java │ │ │ ├── FilteredReport.java │ │ │ ├── HightlightFilteredReport.java │ │ │ ├── MethodCoverageComparisonReport.html │ │ │ ├── MultiHTMLReport.java │ │ │ ├── SingleHTMLReport.java │ │ │ ├── TextReport.java │ │ │ ├── coverage.css │ │ │ ├── jdk │ │ │ ├── JDKComparisonReport.html │ │ │ ├── JDKComparisonReport.java │ │ │ ├── JDKDiffCoverageReport.java │ │ │ ├── JDKLostKeptReport.html │ │ │ └── JDKLostKeptReport.java │ │ │ └── sorttable.js │ └── test │ │ └── openjdk │ │ └── codetools │ │ └── jcov │ │ └── report │ │ ├── commandline │ │ └── CommandLineTest.java │ │ ├── filter │ │ ├── GitDifFilterTest.java │ │ ├── JavaObjectInputStreamAccess.java.txt │ │ ├── ObjectInputStream.java.txt │ │ ├── UnchangedCodeFilterTest.java │ │ └── negative_array_size.diff │ │ ├── jcov │ │ ├── Fake.xml │ │ ├── JCovLoadTest.java │ │ ├── JCovReportTest.java │ │ ├── LostKeptTest.java │ │ ├── ObjectInputStream.xml │ │ ├── ObjectInputStreamTwoMethods.xml │ │ ├── SameLineMethods.java │ │ └── negative_array_size.diff │ │ ├── source │ │ ├── ContextFilterTest.java │ │ └── SourceHierarchyUnionTest.java │ │ └── view │ │ ├── CoverageCacheTest.java │ │ ├── MultiFilesReportTest.java │ │ ├── SingleFileReportTest.java │ │ └── TextReportTest.java ├── data_coverage │ ├── .gitignore │ ├── README.md │ ├── build.xml │ ├── src │ │ └── openjdk │ │ │ └── jcov │ │ │ └── data │ │ │ ├── Env.java │ │ │ ├── Instrument.java │ │ │ ├── JREInstr.java │ │ │ ├── arguments │ │ │ ├── analysis │ │ │ │ ├── Reader.java │ │ │ │ └── package-info.java │ │ │ ├── instrument │ │ │ │ ├── MethodFilter.java │ │ │ │ ├── Plugin.java │ │ │ │ └── package-info.java │ │ │ └── runtime │ │ │ │ ├── Collect.java │ │ │ │ ├── Coverage.java │ │ │ │ ├── Implantable.java │ │ │ │ ├── Saver.java │ │ │ │ ├── Serializer.java │ │ │ │ └── package-info.java │ │ │ ├── instrument │ │ │ └── TypeDescriptor.java │ │ │ └── serialization │ │ │ ├── EnumDeserializer.java │ │ │ └── EnumSerializer.java │ └── test │ │ └── openjdk │ │ └── jcov │ │ └── data │ │ ├── EnvTest.java │ │ ├── arguments │ │ ├── CoverageTest.java │ │ ├── enums │ │ │ ├── EnumMethodsFilter.java │ │ │ ├── EnumTest.java │ │ │ └── UserCode.java │ │ ├── jreinstr │ │ │ └── filepermission │ │ │ │ ├── Main.java │ │ │ │ ├── PermissionMethodFilter.java │ │ │ │ ├── Plugin.java │ │ │ │ ├── Serializer.java │ │ │ │ ├── Test.java │ │ │ │ └── VoidPlugin.java │ │ ├── main │ │ │ ├── MainFilter.java │ │ │ ├── MainTest.java │ │ │ ├── StringArrayDeserializer.java │ │ │ ├── StringArraySerializer.java │ │ │ ├── UserCode.java │ │ │ └── UserCodeStatic.java │ │ └── test │ │ │ ├── ArgumentsTest.java │ │ │ └── UserCode.java │ │ ├── instrumentation.properties │ │ └── lib │ │ ├── TestStatusListener.java │ │ └── Util.java └── simple_methods_anc │ ├── .gitignore │ ├── README.md │ ├── build.xml │ ├── src │ └── openjdk │ │ └── jcov │ │ └── filter │ │ └── simplemethods │ │ ├── Delegators.java │ │ ├── EmptyMethods.java │ │ ├── Getters.java │ │ ├── Scanner.java │ │ ├── Setters.java │ │ ├── Throwers.java │ │ └── Utils.java │ └── test │ └── openjdk │ └── jcov │ └── filter │ └── simplemethods │ ├── DelegatorsTest.java │ ├── EmptyMethodsTest.java │ ├── GettersTest.java │ ├── MainTest.java │ ├── SettersTest.java │ ├── TestUtils.java │ └── ThrowersTest.java ├── src └── classes │ ├── .gitignore │ ├── com │ └── sun │ │ └── tdk │ │ └── jcov │ │ ├── Agent.java │ │ ├── DiffCoverage.java │ │ ├── Exec.java │ │ ├── Filter.java │ │ ├── Grabber.java │ │ ├── GrabberManager.java │ │ ├── Helper.java │ │ ├── Instr.java │ │ ├── Instr2.java │ │ ├── IssueCoverage.java │ │ ├── JCov.java │ │ ├── JREInstr.java │ │ ├── Merger.java │ │ ├── ProductInstr.java │ │ ├── RepGen.java │ │ ├── RepMerge.java │ │ ├── TmplGen.java │ │ ├── ant │ │ ├── AllTasks.java │ │ ├── AntableSPI.java │ │ ├── Grabber.java │ │ ├── GrabberManager.java │ │ ├── Instrument.java │ │ ├── Merge.java │ │ └── Report.java │ │ ├── api │ │ ├── API.java │ │ ├── APIReader.java │ │ ├── APIWriter.java │ │ ├── AbstractDescr.java │ │ ├── Attribute.java │ │ ├── ClassDescr.java │ │ ├── FileFormatException.java │ │ └── MemberDescr.java │ │ ├── constants │ │ ├── InstrConstants.java │ │ ├── MiscConstants.java │ │ └── VMConstants.java │ │ ├── data │ │ ├── FileFormatException.java │ │ ├── Result.java │ │ ├── Scale.java │ │ └── ScaleOptions.java │ │ ├── filter │ │ ├── AcceptAllSpi.java │ │ ├── ConveyerFilter.java │ │ ├── FilterFactory.java │ │ ├── FilterSpi.java │ │ ├── MemberFilter.java │ │ └── package-info.java │ │ ├── insert │ │ └── AbstractUniversalInstrumenter.java │ │ ├── instrument │ │ ├── BasicBlock.java │ │ ├── CharacterRangeTable.java │ │ ├── Constants.java │ │ ├── DataAbstract.java │ │ ├── DataAnnotated.java │ │ ├── DataBlock.java │ │ ├── DataBlockCatch.java │ │ ├── DataBlockFallThrough.java │ │ ├── DataBlockMethEnter.java │ │ ├── DataBlockTarget.java │ │ ├── DataBlockTargetCase.java │ │ ├── DataBlockTargetCond.java │ │ ├── DataBlockTargetDefault.java │ │ ├── DataBlockTargetGoto.java │ │ ├── DataBranch.java │ │ ├── DataBranchCond.java │ │ ├── DataBranchGoto.java │ │ ├── DataBranchSwitch.java │ │ ├── DataClass.java │ │ ├── DataExit.java │ │ ├── DataExitSimple.java │ │ ├── DataField.java │ │ ├── DataMethod.java │ │ ├── DataMethodEntryOnly.java │ │ ├── DataMethodInvoked.java │ │ ├── DataMethodWithBlocks.java │ │ ├── DataPackage.java │ │ ├── DataRoot.java │ │ ├── InstrumentationOptions.java │ │ ├── InstrumentationParams.java │ │ ├── InstrumentationPlugin.java │ │ ├── LocationAbstract.java │ │ ├── LocationConcrete.java │ │ ├── LocationRef.java │ │ ├── MergeException.java │ │ ├── Modifiers.java │ │ ├── SimpleBasicBlock.java │ │ ├── XmlContext.java │ │ ├── XmlNames.java │ │ ├── asm │ │ │ ├── ASMInstrumentationPlugin.java │ │ │ ├── ASMModifiers.java │ │ │ ├── ASMUtils.java │ │ │ ├── BlockCodeMethodAdapter.java │ │ │ ├── BranchCodeMethodAdapter.java │ │ │ ├── CharacterRangeTableAttribute.java │ │ │ ├── ClassMorph.java │ │ │ ├── ClassMorph2.java │ │ │ ├── DeferringMethodClassAdapter.java │ │ │ ├── EntryCodeMethodAdapter.java │ │ │ ├── FieldAnnotationVisitor.java │ │ │ ├── ForkingMethodAdapter.java │ │ │ ├── InstrumentedAttributeClassAdapter.java │ │ │ ├── Instrumenter.java │ │ │ ├── InvokeClassAdapter.java │ │ │ ├── InvokeMethodAdapter.java │ │ │ ├── MethodAnnotationAdapter.java │ │ │ ├── NativeWrappingMethodAdapter.java │ │ │ ├── OffsetLabel.java │ │ │ ├── OffsetLabelingClassReader.java │ │ │ ├── OffsetRecordingMethodAdapter.java │ │ │ ├── OverriddenClassWriter.java │ │ │ ├── SavePointsMethodAdapter.java │ │ │ └── StaticInvokeMethodAdapter.java │ │ ├── package-info.java │ │ └── reader │ │ │ ├── BasicBlockStAX.java │ │ │ ├── CharacterRangeTableAttributeStAX.java │ │ │ ├── DataAnnotatedStAX.java │ │ │ ├── DataBlockStAX.java │ │ │ ├── DataBranchCondStAX.java │ │ │ ├── DataBranchGotoStAX.java │ │ │ ├── DataBranchSwitchStAX.java │ │ │ ├── DataClassStAX.java │ │ │ ├── DataExitSimpleStAX.java │ │ │ ├── DataFieldStAX.java │ │ │ ├── DataMethodStAX.java │ │ │ ├── DataMethodWithBlocksStAX.java │ │ │ ├── DataRootStAX.java │ │ │ ├── LocationConcreteStAX.java │ │ │ ├── LocationRefStAX.java │ │ │ ├── Reader.java │ │ │ ├── ReaderFactory.java │ │ │ ├── ReaderFactoryStAX.java │ │ │ ├── RootReader.java │ │ │ └── SimpleBasicBlockStAX.java │ │ ├── io │ │ ├── ClassSignatureFilter.java │ │ └── Reader.java │ │ ├── logging.properties │ │ ├── package-info.java │ │ ├── processing │ │ ├── CombinerDataProcessor.java │ │ ├── ConveyerProcessor.java │ │ ├── DataProcessor.java │ │ ├── DataProcessorFactory.java │ │ ├── DataProcessorSPI.java │ │ ├── DefaultDataProcessorSPI.java │ │ ├── ProcessingException.java │ │ ├── StubSpi.java │ │ └── package-info.java │ │ ├── report │ │ ├── AbstractCoverage.java │ │ ├── AncFilter.java │ │ ├── AncFilterFactory.java │ │ ├── ClassCoverage.java │ │ ├── CoverageData.java │ │ ├── DataType.java │ │ ├── DefaultReportGeneratorSPI.java │ │ ├── FieldCoverage.java │ │ ├── ItemCoverage.java │ │ ├── LineCoverage.java │ │ ├── MemberCoverage.java │ │ ├── MethodCoverage.java │ │ ├── PackageCoverage.java │ │ ├── ParameterizedAncFilter.java │ │ ├── ProductCoverage.java │ │ ├── ReportGenerator.java │ │ ├── ReportGeneratorSPI.java │ │ ├── SmartTestService.java │ │ ├── SubpackageCoverage.java │ │ ├── Test.java │ │ ├── ancfilters │ │ │ ├── BuiltInAncFilters.java │ │ │ ├── CatchANCFilter.java │ │ │ ├── DefaultAncFilter.java │ │ │ ├── DeprecatedANCFilter.java │ │ │ ├── EmptyANCFilter.java │ │ │ ├── GetterANCFilter.java │ │ │ ├── ListANCFilter.java │ │ │ ├── SetterANCFilter.java │ │ │ ├── SyntheticANCFilter.java │ │ │ ├── ThrowANCFilter.java │ │ │ └── ToStringANCFilter.java │ │ ├── html │ │ │ ├── CoverageReport.java │ │ │ ├── JavaToHtml.java │ │ │ └── resources │ │ │ │ ├── CopyResources.java │ │ │ │ ├── sorttable.js │ │ │ │ └── style.css │ │ ├── javap │ │ │ ├── JavapClass.java │ │ │ ├── JavapClassReader.java │ │ │ ├── JavapCodeLine.java │ │ │ ├── JavapLine.java │ │ │ └── JavapRepGen.java │ │ ├── package-info.java │ │ └── text │ │ │ └── TextReportGenerator.java │ │ ├── runtime │ │ ├── AgentSocketSaver.java │ │ ├── Collect.java │ │ ├── CollectDetect.java │ │ ├── FileSaver.java │ │ ├── JCovSEServerSocketSaver.java │ │ ├── JCovSESocketSaver.java │ │ ├── JCovSaver.java │ │ ├── JCovServerSocketSaver.java │ │ ├── JCovSocketSaver.java │ │ ├── JCovXMLFileSaver.java │ │ ├── NetworkSatelliteDecorator.java │ │ ├── PropertyFinder.java │ │ ├── SaverDecorator.java │ │ └── TemplateFileSaver.java │ │ ├── tools │ │ ├── DeflaterScaleCompressor.java │ │ ├── DelegateIterator.java │ │ ├── EnvHandler.java │ │ ├── EnvServiceProvider.java │ │ ├── JCovCMDTool.java │ │ ├── JCovTool.java │ │ ├── JcovStats.java │ │ ├── JcovVersion.java │ │ ├── LoggingFormatter.java │ │ ├── OneElemIterator.java │ │ ├── OptionDescr.java │ │ ├── SPIDescr.java │ │ ├── ScaleCompressor.java │ │ ├── ServiceProvider.java │ │ ├── SimpleScaleCompressor.java │ │ └── package-info.java │ │ └── util │ │ ├── AddToProduct.java │ │ ├── DebugUtils.java │ │ ├── MapHelper.java │ │ ├── NaturalComparator.java │ │ ├── RuntimeUtils.java │ │ └── Utils.java │ └── jcov │ └── JTObserver.java └── test └── unit └── com └── sun └── tdk └── jcov ├── instrument ├── IntrumentNestHostTest.java ├── Util.java ├── ZipTest.java ├── instr │ ├── InstrTest.java │ └── UserCode.java ├── jreinstr │ ├── Code.java │ └── JREInstrTest.java └── plugin │ ├── FieldsClass.java │ ├── FieldsPlugin.java │ ├── FieldsTest.java │ └── jreinstr │ ├── Collect.java │ ├── JREInstrTest.java │ └── TestPlugin.java ├── lib └── InstrProxy.java └── report ├── BasicReportTest.java ├── BasicUserCode.java ├── RecordContainer.java ├── RecordContainerTest.java ├── ReportTest.java ├── ancfilters ├── BuiltInAncFiltersTest.java └── ListANCFilterTest.java └── dataprocessor ├── privacy ├── PrivacyTest.java └── privacy_template.xml └── syntheticity ├── SyntheticityTest.java └── synthetic_template.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # Package Files 8 | *.jar 9 | *.zip 10 | *.tar.gz 11 | *.tar 12 | 13 | # virtual machine crash logs 14 | hs_err_pid* 15 | 16 | # Misc: Intellij Idea,Mac OS 17 | /.idea/ 18 | *.iml 19 | .DS_Store 20 | 21 | # build 22 | JCOV_BUILD/ 23 | build/template.xml 24 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | 3 | # IDEA modules 4 | **.iml 5 | 6 | # build 7 | JCOV_BUILD/** 8 | 9 | # Misc 10 | webrev/** 11 | webrev.zip 12 | *~ 13 | *.log 14 | *.swp 15 | 16 | # MAC OS 17 | *.DS_Store 18 | -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | bfc1e6ee1dfa79d9ea7d2f96cdf34fc5d8650339 jcov2.0 2 | 1bfff4a9a00a879ee106dcbc0fc065ccf3bfc6fd jcov3.0-rc0 3 | d63621272f746de6ab744df2c0b4ec668a5ffd1f jcov3.0-b04 4 | 1bfff4a9a00a879ee106dcbc0fc065ccf3bfc6fd jcov3.0-rc0 5 | 0000000000000000000000000000000000000000 jcov3.0-rc0 6 | 0000000000000000000000000000000000000000 jcov3.0-rc0 7 | 1bfff4a9a00a879ee106dcbc0fc065ccf3bfc6fd jcov3.0-rc0 8 | 0ad271c037d53c784aca60631a60925990d45fb2 jcov3.0-b05 9 | 18b0a143e1c231424b79f5a212d893ceb1814b69 jcov3.0-b06 10 | 7809411148e07aff8687a8953627cb857d55947b jcov3.0-b07 11 | -------------------------------------------------------------------------------- /.jcheck/conf: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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. 8 | ; 9 | ; This code is distributed in the hope that it will be useful, but WITHOUT 10 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | ; version 2 for more details (a copy is included in the LICENSE file that 13 | ; accompanied this code). 14 | ; 15 | ; You should have received a copy of the GNU General Public License version 16 | ; 2 along with this work; if not, write to the Free Software Foundation, 17 | ; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ; 19 | ; Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 | ; or visit www.oracle.com if you need additional information or have any 21 | ; questions. 22 | ; 23 | 24 | [general] 25 | project=code-tools 26 | repository=jcov 27 | jbs=codetools 28 | 29 | [checks] 30 | error=author,committer,whitespace,executable,symlink 31 | 32 | [census] 33 | version=0 34 | domain=openjdk.org 35 | 36 | [checks "whitespace"] 37 | files=.*\.java$|.*\.c$|.*\.h$|.*\.cpp$|.*\.hpp$ 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenJDK JCov 2 | 3 | The JCov open source project is used to gather quality metrics associated with the production of test suites. JCov is being opened in order to facilitate the practice of verifying test execution of regression tests in OpenJDK development. 4 | 5 | The main motivation behind JCov is *transparency of test coverage metrics*. The advantage to promoting standard coverage based on JCov is that OpenJDK developers will be able to use a code coverage tool that stays in 'lock step' with Java language and VM developments. 6 | 7 | JCov is a pure java implementation of a code coverage tool which provides a means to measure and analyze dynamic code coverage of Java programs. JCov provides functionality to collect method, linear block and branch coverage, as well as showing uncovered execution paths. It is also able to show a program's source code annotated with coverage information. 8 | 9 | From a testing perspective, JCov is most useful to determine execution paths (in a Java application) that a test suite is (or is not) executing. 10 | JCov supports applications on JDK 1.0 and higher (including JDK 14), CDC/CLDC 1.0 and higher, and JavaCard 3.0 and higher. 11 | The JCov open source project is created in order to develop a community that will improve it, further its development, and use it to develop test suites. We encourage you to browse, download, contribute, and get involved. 12 | -------------------------------------------------------------------------------- /THIRD-PARTY: -------------------------------------------------------------------------------- 1 | DO NOT TRANSLATE OR LOCALIZE. 2 | ----------------------------- 3 | 4 | %% This notice is provided with respect to ASM 5.0_BETA 5 | 6 | --- begin of LICENSE --- 7 | 8 | Copyright (c) 2000-2011 INRIA, France Telecom 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions 13 | are met: 14 | 1. Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | 2. Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | 3. Neither the name of the copyright holders nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 27 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 33 | THE POSSIBILITY OF SUCH DAMAGE. 34 | 35 | --- end of LICENSE --- -------------------------------------------------------------------------------- /build/build.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 2025, 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 | 24 | # sha1 checksum for asm libraries 25 | asm.checksum = 11ae50d25b0fec4cff74a2c6b217280d9c727b52 26 | asm.tree.checksum = b7eceb80554b955d73cea443f143d945f87755a5 27 | asm.util.checksum = 9a3fb3a5cd6364dc5ca86d832093d7bcaa4ac927 28 | 29 | # default dir to cumualte deps 30 | deps.dir=./lib 31 | 32 | # path to asm libraries 33 | asm.version=9.8 34 | asm.jar = ${deps.dir}/asm-${asm.version}.jar 35 | asm.tree.jar = ${deps.dir}/asm-tree-${asm.version}.jar 36 | asm.util.jar = ${deps.dir}/asm-util-${asm.version}.jar 37 | 38 | # path to javatest library (empty value allowed if you do not need jtobserver.jar) 39 | javatestjar = ${deps.dir}/javatest.jar 40 | 41 | # path to TestNG library 42 | testngver = 6.9.10 43 | testngjar = ${deps.dir}/testng-${testngver}.jar 44 | 45 | # path to JCommander library 46 | jcommanderver = 1.82 47 | jcommanderjar = ${deps.dir}/jcommander-${jcommanderver}.jar 48 | 49 | # path to output directory 50 | result.dir =../JCOV_BUILD 51 | # path to jcov sources 52 | src.dir = ../src/classes 53 | # path to jcov test sources 54 | test.src.dir = ../test/unit 55 | -------------------------------------------------------------------------------- /build/filesaver.replace.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 2022, 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 | 24 | FILE_SAVER= saver = new TemplateFileSaver(); -------------------------------------------------------------------------------- /build/networksaver.replace.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 2022, 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 | 24 | NETWORK_SAVER= saver = new JCovSESocketSaver(); -------------------------------------------------------------------------------- /build/release.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 2024, 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 | 24 | build.version = 3.0 25 | build.milestone = os.ea 26 | build.number = 14 27 | -------------------------------------------------------------------------------- /examples/tutorial/example3/static_instr_file.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 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /examples/tutorial/example4/one_command.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/tutorial/example5/jcov_ant_tasks.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 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/tutorial/src/com/oracle/demoapp/Plane.java: -------------------------------------------------------------------------------- 1 | package com.oracle.demoapp; 2 | 3 | import com.oracle.demoapp.figures.abstractpack.Figure; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class Plane { 8 | 9 | ArrayList
figures; 10 | 11 | public Plane(){ 12 | figures = new ArrayList
(); 13 | } 14 | 15 | public void addFigure(Figure figure){ 16 | figures.add(figure); 17 | } 18 | 19 | public double countRedFiguresArea(){ 20 | double result = 0; 21 | for (Figure figure : figures){ 22 | if ("red".equals(figure.getColorName().toLowerCase())){ 23 | result+=figure.getArea(); 24 | } 25 | } 26 | return result; 27 | } 28 | 29 | public double countGreenFiguresArea(){ 30 | double result = 0; 31 | for (Figure figure : figures){ 32 | if ("green".equals(figure.getColorName().toLowerCase())){ 33 | result+=figure.getArea(); 34 | } 35 | } 36 | return result; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /examples/tutorial/src/com/oracle/demoapp/figures/Disk.java: -------------------------------------------------------------------------------- 1 | package com.oracle.demoapp.figures; 2 | 3 | import com.oracle.demoapp.figures.abstractpack.Figure; 4 | 5 | public class Disk extends Figure { 6 | 7 | private int length; 8 | 9 | public Disk(int l, String color){ 10 | length = l; 11 | setColorName(color); 12 | } 13 | 14 | @Override 15 | public double getArea() { 16 | return Math.PI*length*length; 17 | } 18 | } -------------------------------------------------------------------------------- /examples/tutorial/src/com/oracle/demoapp/figures/Square.java: -------------------------------------------------------------------------------- 1 | package com.oracle.demoapp.figures; 2 | 3 | import com.oracle.demoapp.figures.abstractpack.Figure; 4 | 5 | public class Square extends Figure { 6 | 7 | private int length; 8 | 9 | public Square(int l, String color){ 10 | length = l; 11 | setColorName(color); 12 | } 13 | 14 | @Override 15 | public double getArea() { 16 | return length * length; 17 | } 18 | } -------------------------------------------------------------------------------- /examples/tutorial/src/com/oracle/demoapp/figures/abstractpack/Figure.java: -------------------------------------------------------------------------------- 1 | package com.oracle.demoapp.figures.abstractpack; 2 | 3 | public abstract class Figure{ 4 | 5 | private String colorName; 6 | 7 | public Figure(){ 8 | } 9 | 10 | public String getColorName(){ 11 | return colorName; 12 | } 13 | 14 | public void setColorName(String colorName){ 15 | this.colorName = colorName; 16 | } 17 | 18 | public abstract double getArea(); 19 | 20 | } -------------------------------------------------------------------------------- /examples/tutorial/test/TestDemoApp1.java: -------------------------------------------------------------------------------- 1 | import com.oracle.demoapp.Plane; 2 | import com.oracle.demoapp.figures.Disk; 3 | import com.oracle.demoapp.figures.Square; 4 | 5 | public class TestDemoApp1{ 6 | 7 | public static void main(String[] args){ 8 | Plane plane = new Plane(); 9 | Square square = new Square(2, "Red"); 10 | Disk disc = new Disk(3, "Green"); 11 | plane.addFigure(square); 12 | plane.addFigure(disc); 13 | 14 | if (plane.countRedFiguresArea() != 4) { 15 | throw new RuntimeException("TestDemoApp1 test failed!"); 16 | } else { 17 | System.out.println("TestDemoApp1 test passed"); 18 | } 19 | 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /examples/tutorial/test/TestDemoApp2.java: -------------------------------------------------------------------------------- 1 | import com.oracle.demoapp.Plane; 2 | 3 | public class TestDemoApp2{ 4 | 5 | public static void main(String[] args){ 6 | Plane plane = new Plane(); 7 | 8 | if (plane.countGreenFiguresArea() != 0) { 9 | throw new RuntimeException("TestDemoApp2 test failed!"); 10 | } else { 11 | System.out.println("TestDemoApp2 test passed"); 12 | } 13 | 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /examples/tutorial/tutorial.build.properties: -------------------------------------------------------------------------------- 1 | # relative path to output directory 2 | tutorial.result.dir = DEMOAPP_BUILD 3 | # relative path to jcov build directory 4 | jcov.result.dir = ../../../../JCOV_BUILD/jcov_2.0 5 | jcov.jar = ${jcov.result.dir}/jcov.jar 6 | jcov.network.saver.jar = ${jcov.result.dir}/jcov_network_saver.jar 7 | jcov.file.saver.jar = ${jcov.result.dir}/jcov_file_saver.jar 8 | 9 | java_home = ${java.home} -------------------------------------------------------------------------------- /examples/tutorial/tutorial.build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /plugins/coberturaXML/README.md: -------------------------------------------------------------------------------- 1 | # JCov plugin for the coverage reports 2 | ##### *Eric L. McCorkle and Alexey Fedorchenko, March 2018, version 1.0* 3 | 4 | This is a plugin to JCov report generation process that adds capability to produce Cobertura XML report. 5 | With this plugin, JCov users can generate Cobertura XML report that can be used as an input for Jenkins 6 | Cobertura plugin. 7 | 8 | ### Folder layout 9 | 10 | The output of this folder is as follows: 11 | 12 | ``` 13 | coberturaXML 14 | |-src (plugin sources) 15 | |-build (build files are stored here) 16 | |-tests (the directory for the tests that verify plugin functionality) 17 | |-plugin (generated directory by the build.xml with the plugin binaries) 18 | |-plugin-tests (generated directory by the tests.xml with tests' results for the plugin) 19 | ``` 20 | 21 | ### Building the plugin 22 | 23 | To build the plugin, you need to have Apache Ant. The plugin can be built by running `ant -f build/build.xml` from the 24 | current directory. The properties used during the build are specified at `build/build.properties`: 25 | 26 | * You might need to specify path to JCov binaries that are used during the plugin build with the property `jcov.path` 27 | 28 | * The `plugin` directory with the plugin binaries will be generated by the command. The property `result.dir` is used 29 | to specify the path to the result directory. 30 | 31 | ### Testing the plugin 32 | 33 | To run tests on the plugin, you need to execute `ant -f tests/tests.xml` command. This command will invoke 34 | all `test.xml` files in the `tests` subdirectories. To add a new test you can create new subdirectory with 35 | the `test.xml` file. The common test properties are described in `tests/tests.properties` 36 | 37 | ### Using the plugin 38 | To produce Cobertura XML report in `cobertura.xml` file from the JCov `result.xml` file you need to specify 39 | JCov property `jcov.customreport.spi` and add the plugin classes to classpath: 40 | ``` 41 | java -Djcov.customreport.spi=openjdk.codetools.jcov.plugin.coberturaxml.CoberturaReportGeneratorSPI 42 | -cp jcov.jar:coberturaXML.jar com.sun.tdk.jcov.RepGen -format cobertura -o cobertura.xml result.xml 43 | ``` 44 | 45 | 46 | ### Dealing with bugs 47 | 48 | Please forward plugin bugs and patches to `jcov-dev@openjdk.java.net`. -------------------------------------------------------------------------------- /plugins/coberturaXML/build/build.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018, 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 | 24 | result.dir=../plugin 25 | jcov.path=../../../JCOV_BUILD/jcov_3.0/jcov.jar -------------------------------------------------------------------------------- /plugins/coberturaXML/build/build.xml: -------------------------------------------------------------------------------- 1 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /plugins/coberturaXML/tests/tests.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018, 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 | 24 | tests.result.dir=../plugin_tests 25 | jcov.path=../../../JCOV_BUILD/jcov_3.0/jcov.jar 26 | jcov.coberturaxml.plugin.path=../plugin/dist/coberturaXML.jar 27 | -------------------------------------------------------------------------------- /plugins/coberturaXML/tests/tests.xml: -------------------------------------------------------------------------------- 1 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /plugins/coverage_reports/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /plugins/coverage_reports/README.md: -------------------------------------------------------------------------------- 1 | # Additional JCov reports 2 | 3 | This module contains source code implementing varions code coverage reporting 4 | aproaches. 5 | 6 | Currently implemented report formats: 7 | 1. Single-file html. 8 | 2. Text. 9 | 10 | Currently implemented reports: 11 | 1. Diff coverage report. See JDKReport for an example of usage. Next input needs to be provided: 12 | 1. Coverage data in form of JCov file 13 | 2. Diff file (only output of git diff has been tested so far) 14 | 3. Source code 15 | 16 | -------------------------------------------------------------------------------- /plugins/coverage_reports/src/openjdk/codetools/jcov/report/CoveredLineRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.codetools.jcov.report; 26 | 27 | /** 28 | * The assumption is that some coverage information can be linked to a portion of source code. 29 | * @see Coverage 30 | * @see FileCoverage 31 | */ 32 | public class CoveredLineRange extends LineRange { 33 | private final Coverage coverage; 34 | public CoveredLineRange(int first, int last, Coverage coverage) { 35 | super(first, last); 36 | this.coverage = coverage; 37 | } 38 | 39 | public Coverage coverage() { 40 | return coverage; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /plugins/coverage_reports/src/openjdk/codetools/jcov/report/FileCoverage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.codetools.jcov.report; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Presents a coverage of a file in terms of line ranges. 31 | * @see LineRange 32 | * @see CoveredLineRange 33 | * @see Coverage 34 | */ 35 | public interface FileCoverage { 36 | List ranges(String file); 37 | } 38 | -------------------------------------------------------------------------------- /plugins/coverage_reports/src/openjdk/codetools/jcov/report/commandline/Parameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.codetools.jcov.report.commandline; 26 | 27 | public class Parameter { 28 | private final String name; 29 | private final String description; 30 | 31 | public Parameter(String name, String description) { 32 | this.name = name; 33 | this.description = description; 34 | } 35 | 36 | public String name() { 37 | return name; 38 | } 39 | 40 | public String description() { 41 | return description; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /plugins/coverage_reports/src/openjdk/codetools/jcov/report/filter/SourceFileFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, 2024 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.codetools.jcov.report.filter; 26 | 27 | import java.util.Set; 28 | 29 | /** 30 | * A source filter which is also aware of what files need to be included. 31 | */ 32 | public interface SourceFileFilter extends SourceFilter { 33 | Set files(); 34 | } 35 | -------------------------------------------------------------------------------- /plugins/coverage_reports/src/openjdk/codetools/jcov/report/filter/SourceFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.codetools.jcov.report.filter; 26 | 27 | import openjdk.codetools.jcov.report.LineRange; 28 | 29 | import java.util.List; 30 | 31 | /** 32 | * Filters a source file by providing a list of line ranges which needs not be included. 33 | * @see LineRange 34 | */ 35 | public interface SourceFilter { 36 | 37 | /** 38 | * Line ranges to be included. Any implementaiton is assumed to return a list of line that is ordered 39 | * by beginning line. 40 | * @param file 41 | * @return 42 | */ 43 | List ranges(String file); 44 | 45 | default boolean includes(String file, int line) { 46 | return ranges(file).stream().anyMatch(r -> r.compare(line) == 0); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /plugins/coverage_reports/test/openjdk/codetools/jcov/report/filter/JavaObjectInputStreamAccess.java.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, 2018, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package jdk.internal.access; 27 | 28 | import java.io.ObjectStreamException; 29 | import java.io.ObjectInputStream; 30 | 31 | /** 32 | * Interface to specify methods for accessing {@code ObjectInputStream}. 33 | */ 34 | @FunctionalInterface 35 | public interface JavaObjectInputStreamAccess { 36 | void checkArray(ObjectInputStream ois, Class arrayType, int arrayLength) 37 | throws ObjectStreamException; 38 | } 39 | -------------------------------------------------------------------------------- /plugins/coverage_reports/test/openjdk/codetools/jcov/report/filter/negative_array_size.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/ObjectInputStream.java b/src/ObjectInputStream.java 2 | index 2e0d6384f81..10b7f7715fa 100644 3 | --- a/src/ObjectInputStream.java 4 | +++ b/src/ObjectInputStream.java 5 | @@ -1454 +1454 @@ public class ObjectInputStream 6 | - * @throws NegativeArraySizeException if arrayLength is negative 7 | + * @throws StreamCorruptedException if arrayLength is negative 8 | @@ -1457 +1457 @@ public class ObjectInputStream 9 | - private void checkArray(Class arrayType, int arrayLength) throws InvalidClassException { 10 | + private void checkArray(Class arrayType, int arrayLength) throws ObjectStreamException { 11 | @@ -1463 +1463 @@ public class ObjectInputStream 12 | - throw new NegativeArraySizeException(); 13 | + throw new StreamCorruptedException("Array length is negative"); 14 | @@ -2141 +2141,3 @@ public class ObjectInputStream 15 | - 16 | + if (len < 0) { 17 | + throw new StreamCorruptedException("Array length is negative"); 18 | + } 19 | diff --git a/src/JavaObjectInputStreamAccess.java b/src/JavaObjectInputStreamAccess.java 20 | index 2633ac0edca..a47add473c6 100644 21 | --- a/src/JavaObjectInputStreamAccess.java 22 | +++ b/src/JavaObjectInputStreamAccess.java 23 | @@ -28 +28 @@ package jdk.internal.access; 24 | -import java.io.InvalidClassException; 25 | +import java.io.ObjectStreamException; 26 | @@ -37 +37 @@ public interface JavaObjectInputStreamAccess { 27 | - throws InvalidClassException; 28 | + throws ObjectStreamException; 29 | -------------------------------------------------------------------------------- /plugins/coverage_reports/test/openjdk/codetools/jcov/report/jcov/Fake.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 0=1;1=1; 38 | 39 | 40 | 41 | 42 | 43 | 2=1;3=1; 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /plugins/coverage_reports/test/openjdk/codetools/jcov/report/jcov/negative_array_size.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/java/io/ObjectInputStream.java b/src/java/io/ObjectInputStream.java 2 | index 2e0d6384f81..10b7f7715fa 100644 3 | --- a/src/java/io/ObjectInputStream.java 4 | +++ b/src/java/io/ObjectInputStream.java 5 | @@ -1454 +1454 @@ public class ObjectInputStream 6 | - * @throws NegativeArraySizeException if arrayLength is negative 7 | + * @throws StreamCorruptedException if arrayLength is negative 8 | @@ -1457 +1457 @@ public class ObjectInputStream 9 | - private void checkArray(Class arrayType, int arrayLength) throws InvalidClassException { 10 | + private void checkArray(Class arrayType, int arrayLength) throws ObjectStreamException { 11 | @@ -1463 +1463 @@ public class ObjectInputStream 12 | - throw new NegativeArraySizeException(); 13 | + throw new StreamCorruptedException("Array length is negative"); 14 | @@ -2141 +2141,3 @@ public class ObjectInputStream 15 | - 16 | + if (len < 0) { 17 | + throw new StreamCorruptedException("Array length is negative"); 18 | + } 19 | diff --git a/src/java/io/JavaObjectInputStreamAccess.java b/src/java/io/JavaObjectInputStreamAccess.java 20 | index 2633ac0edca..a47add473c6 100644 21 | --- a/src/java/io/JavaObjectInputStreamAccess.java 22 | +++ b/src/java/io/JavaObjectInputStreamAccess.java 23 | @@ -28 +28 @@ package jdk.internal.access; 24 | -import java.io.InvalidClassException; 25 | +import java.io.ObjectStreamException; 26 | @@ -37 +37 @@ public interface JavaObjectInputStreamAccess { 27 | - throws InvalidClassException; 28 | + throws ObjectStreamException; 29 | -------------------------------------------------------------------------------- /plugins/coverage_reports/test/openjdk/codetools/jcov/report/source/ContextFilterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.codetools.jcov.report.source; 26 | 27 | import openjdk.codetools.jcov.report.LineRange; 28 | import openjdk.codetools.jcov.report.filter.SourceFilter; 29 | import org.testng.Assert; 30 | import org.testng.annotations.Test; 31 | 32 | import java.util.List; 33 | 34 | import static org.testng.Assert.assertEquals; 35 | 36 | public class ContextFilterTest { 37 | @Test 38 | public void sparse() { 39 | var filter = new ContextFilter(new SourceFilter() { 40 | @Override 41 | public List ranges(String file) { 42 | return List.of( 43 | new LineRange(1, 3), 44 | new LineRange(7, 10), 45 | new LineRange(50, 50), 46 | new LineRange(98, 99) 47 | ); 48 | } 49 | }, 2); 50 | var ranges = filter.ranges(""); 51 | assertEquals(ranges.size(), 3); 52 | Assert.assertEquals(ranges.get(0).first(), 1); 53 | Assert.assertEquals(ranges.get(0).last(), 12); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /plugins/data_coverage/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | build 3 | -------------------------------------------------------------------------------- /plugins/data_coverage/README.md: -------------------------------------------------------------------------------- 1 | # JCov data plugin 2 | 3 | This is an implementation of *com.sun.tdk.jcov.instrument.InstrumentationPlugin* plugin which can help with investigating of data flow within Java code. The plugin is intended to add additional instrumentation to collect facts about values used in runtime. 4 | 5 | Currently this repository only contains code allowing to capture information about method arguments. 6 | 7 | Code from *com.sun.tdk.jcov.instrument.plugin* JCov unit tests will later be also migrated into this project to be able to collect data about values assigned to fields. 8 | 9 | WIP! 10 | 11 | Please see tests to find out how this can be used. 12 | -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/arguments/analysis/Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.analysis; 26 | 27 | public class Reader { 28 | } 29 | -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/arguments/analysis/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | * This package will contain API useful for loading, parsing and analizing data coverage data. 27 | */ 28 | package openjdk.jcov.data.arguments.analysis; -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/arguments/instrument/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | * API package for classes used during the instrumentation time. 27 | */ 28 | package openjdk.jcov.data.arguments.instrument; -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/arguments/runtime/Implantable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.runtime; 26 | 27 | import java.util.Collection; 28 | 29 | public interface Implantable { 30 | Collection runtime(); 31 | } 32 | -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/arguments/runtime/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.runtime; 26 | 27 | import java.util.function.Function; 28 | 29 | public interface Serializer extends Implantable, Function { 30 | } 31 | -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/arguments/runtime/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | * This package contains core classes which are needed at runtime. 27 | */ 28 | package openjdk.jcov.data.arguments.runtime; -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/serialization/EnumDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.serialization; 26 | 27 | import java.util.Arrays; 28 | import java.util.function.Function; 29 | 30 | /** 31 | * Restores enum object from its name. 32 | */ 33 | public class EnumDeserializer implements Function { 34 | private final Class enumClass; 35 | 36 | public EnumDeserializer(String enumClassName) throws ClassNotFoundException { 37 | this((Class) Class.forName(enumClassName)); 38 | } 39 | public EnumDeserializer(Class aClass) { 40 | enumClass = aClass; 41 | } 42 | 43 | @Override 44 | public Object apply(String s) { 45 | return Arrays.stream(enumClass.getEnumConstants()).filter(e -> e.name().equals(s)) 46 | .findAny().get(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /plugins/data_coverage/src/openjdk/jcov/data/serialization/EnumSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.serialization; 26 | 27 | import openjdk.jcov.data.arguments.runtime.Implantable; 28 | 29 | import java.util.Collection; 30 | import java.util.List; 31 | import java.util.function.Function; 32 | 33 | /** 34 | * Serializes an enum into its name. 35 | */ 36 | public class EnumSerializer implements Function, Implantable { 37 | 38 | private final String defaultValue; 39 | 40 | public EnumSerializer(String value) { 41 | defaultValue = value; 42 | } 43 | 44 | public EnumSerializer() { 45 | this("NOT_AN_ENUM"); 46 | } 47 | 48 | @Override 49 | public String apply(Object anEnum) { 50 | if (anEnum instanceof Enum) 51 | return ((Enum) anEnum).name(); 52 | else 53 | return defaultValue; 54 | } 55 | 56 | public Collection runtime() { 57 | return List.of(EnumSerializer.class); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/EnvTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data; 26 | 27 | import org.testng.annotations.Test; 28 | 29 | import static org.testng.Assert.assertEquals; 30 | 31 | public class EnvTest { 32 | public static final String TEST_PROPERTY = "jcov.data.test.property"; 33 | public static final String IUNDEFINED_TEST_PROPERTY = "jcov.data.test.property.undefined"; 34 | @Test 35 | public void defaultsTest() { 36 | assertEquals(Env.getStringEnv(TEST_PROPERTY, "three"), "one"); 37 | System.setProperty(TEST_PROPERTY, "two"); 38 | assertEquals(Env.getStringEnv(TEST_PROPERTY, "three"), "two"); 39 | assertEquals(Env.getStringEnv(IUNDEFINED_TEST_PROPERTY, "three"), "three"); 40 | System.setProperty(IUNDEFINED_TEST_PROPERTY, "two"); 41 | assertEquals(Env.getStringEnv(IUNDEFINED_TEST_PROPERTY, "three"), "two"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/enums/EnumMethodsFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.enums; 26 | 27 | import openjdk.jcov.data.arguments.instrument.MethodFilter; 28 | 29 | public class EnumMethodsFilter implements MethodFilter { 30 | @Override 31 | public boolean accept(int access, String owner, String method, String desc) throws ClassNotFoundException { 32 | return MethodFilter.parseDesc(desc).stream().anyMatch(td -> { 33 | try { 34 | return Enum.class.isAssignableFrom(Class.forName(td.cls().replace('/', '.'))); 35 | } catch (ClassNotFoundException e) { 36 | throw new RuntimeException(e); 37 | } 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/enums/UserCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.enums; 26 | 27 | public class UserCode { 28 | public enum ENum {ONE, TWO, THREE}; 29 | public void method(ENum e) { 30 | System.out.println(e); 31 | } 32 | public static void staticMethod(ENum e) { 33 | System.out.println(e); 34 | } 35 | 36 | public static void main(String[] args) { 37 | new UserCode().method(ENum.ONE); 38 | UserCode.staticMethod(ENum.TWO); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/jreinstr/filepermission/Main.java: -------------------------------------------------------------------------------- 1 | package openjdk.jcov.data.arguments.jreinstr.filepermission; 2 | 3 | import openjdk.jcov.data.Env; 4 | 5 | import java.io.File; 6 | import java.io.FilePermission; 7 | import java.io.IOException; 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.nio.file.Files; 10 | import java.nio.file.Path; 11 | import java.util.Objects; 12 | 13 | import static java.util.stream.Collectors.toMap; 14 | 15 | public class Main { 16 | public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { 17 | System.getProperties().storeToXML(System.out, ""); 18 | System.out.println("" + Env.getSPIEnv(openjdk.jcov.data.arguments.runtime.Collect.SERIALIZER, null)); 19 | System.getProperties().entrySet().stream() 20 | .forEach(e -> System.out.println(e.getKey() + " -> " + e.getValue())); 21 | System.out.println(openjdk.jcov.data.arguments.runtime.Collect.SERIALIZER + " = " + System.getProperties().entrySet().stream() 22 | .collect(toMap(Object::toString, Object::toString)).get(openjdk.jcov.data.arguments.runtime.Collect.SERIALIZER)); 23 | Path file = Files.createTempFile("test", ".txt"); 24 | FilePermission filePermission = new FilePermission(file.toString(), "read"); 25 | FilePermission dirPermission = new FilePermission(file.getParent().toString() + "/-", "read,write"); 26 | System.out.println(dirPermission.implies(filePermission)); 27 | Files.delete(file); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/jreinstr/filepermission/PermissionMethodFilter.java: -------------------------------------------------------------------------------- 1 | package openjdk.jcov.data.arguments.jreinstr.filepermission; 2 | 3 | import openjdk.jcov.data.arguments.instrument.MethodFilter; 4 | 5 | import java.io.FilePermission; 6 | 7 | public class PermissionMethodFilter implements MethodFilter { 8 | @Override 9 | public boolean accept(int access, String owner, String name, String desc) throws Exception { 10 | // return false; 11 | return openjdk.jcov.data.arguments.instrument.MethodFilter.parseDesc(desc).stream() 12 | .anyMatch(td -> td.cls().equals(FilePermission.class.getName().replace('.', '/'))); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/jreinstr/filepermission/Plugin.java: -------------------------------------------------------------------------------- 1 | package openjdk.jcov.data.arguments.jreinstr.filepermission; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class Plugin extends openjdk.jcov.data.arguments.instrument.Plugin { 8 | public Plugin() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { 9 | super(); 10 | } 11 | 12 | @Override 13 | protected List runtimeClasses() { 14 | ArrayList result = new ArrayList<>(super.runtimeClasses()); 15 | result.add(Serializer.class); 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/jreinstr/filepermission/Serializer.java: -------------------------------------------------------------------------------- 1 | package openjdk.jcov.data.arguments.jreinstr.filepermission; 2 | 3 | import openjdk.jcov.data.arguments.runtime.Collect; 4 | import openjdk.jcov.data.arguments.runtime.Implantable; 5 | 6 | import java.io.File; 7 | import java.io.FilePermission; 8 | import java.io.IOException; 9 | import java.util.Collection; 10 | import java.util.Set; 11 | 12 | public class Serializer implements openjdk.jcov.data.arguments.runtime.Serializer { 13 | @Override 14 | public String apply(Object o) { 15 | if(o instanceof FilePermission) { 16 | return ((FilePermission)o).getActions(); 17 | } else return null; 18 | } 19 | 20 | @Override 21 | public Collection runtime() { 22 | return Set.of(Serializer.class, 23 | Implantable.class); 24 | } 25 | 26 | public static void main(String[] args) throws IOException { 27 | File file = File.createTempFile("test", ".txt"); 28 | file.delete(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/jreinstr/filepermission/VoidPlugin.java: -------------------------------------------------------------------------------- 1 | package openjdk.jcov.data.arguments.jreinstr.filepermission; 2 | 3 | import com.sun.tdk.jcov.instrument.asm.ASMInstrumentationPlugin; 4 | import org.objectweb.asm.MethodVisitor; 5 | 6 | import java.nio.file.Path; 7 | 8 | public class VoidPlugin implements ASMInstrumentationPlugin { 9 | 10 | public VoidPlugin() { 11 | super(); 12 | } 13 | 14 | @Override 15 | public MethodVisitor methodVisitor(int i, String s, String s1, String s2, MethodVisitor visitor) { 16 | return visitor; 17 | } 18 | 19 | @Override 20 | public void instrumentationComplete() throws Exception { 21 | 22 | } 23 | 24 | @Override 25 | public Path runtime() throws Exception { 26 | return null; 27 | } 28 | 29 | @Override 30 | public String collectorPackage() { 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/main/MainFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.main; 26 | 27 | import openjdk.jcov.data.arguments.instrument.MethodFilter; 28 | import openjdk.jcov.data.arguments.instrument.Plugin; 29 | 30 | import java.lang.reflect.Modifier; 31 | import java.util.List; 32 | 33 | public class MainFilter implements MethodFilter { 34 | @Override 35 | public boolean accept(int access, String owner, String method, String desc) throws ClassNotFoundException { 36 | List params = MethodFilter.parseDesc(desc); 37 | return method.equals("main") && 38 | params.size() == 1 && 39 | (access & Modifier.STATIC) > 0 && 40 | (access & Modifier.PUBLIC) > 0 && 41 | desc.endsWith(")V") && 42 | params.stream().anyMatch(td -> td.id().equals("[")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/main/StringArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.main; 26 | 27 | import java.util.Arrays; 28 | import java.util.List; 29 | import java.util.function.Function; 30 | 31 | import static java.util.stream.Collectors.toList; 32 | 33 | //TODO move this to the source after figuring out TypeDescriptor for arrays 34 | public class StringArrayDeserializer implements Function> { 35 | @Override 36 | public List apply(String s) { 37 | return Arrays.stream(s.split(",")).collect(toList()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/main/StringArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.main; 26 | 27 | import java.util.Arrays; 28 | import java.util.function.Function; 29 | 30 | import static java.util.stream.Collectors.joining; 31 | 32 | //TODO move this to the source after figuring out TypeDescriptor for arrays 33 | public class StringArraySerializer implements Function { 34 | @Override 35 | public String apply(Object o) { 36 | if(o.getClass().isArray() && o.getClass().getComponentType().equals(String.class)) { 37 | return Arrays.stream((String[])o).collect(joining(",")); 38 | } else return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/main/UserCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.main; 26 | 27 | public class UserCode { 28 | public void main(String[] args) {} 29 | public void main(String arg) {} 30 | public void main() {} 31 | } 32 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/main/UserCodeStatic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.main; 26 | 27 | public class UserCodeStatic { 28 | public static void main(String[] args) {} 29 | public static void main(String arg) {} 30 | public static void main() {} 31 | } 32 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/arguments/test/UserCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.data.arguments.test; 26 | 27 | public class UserCode { 28 | public static void method(int i, long j, float f, double d, boolean z, byte b, String s) { 29 | System.out.println("Calling with: " + i + "," + j + "," + f + "," + d + "," + z + "," + b + "," + s); 30 | } 31 | 32 | public static void main(String[] args) { 33 | method(0, 1, 2f, 3., true, (byte)5, "6"); 34 | method(7, 8, 9f, 10d, false, (byte)12, "13"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/instrumentation.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, 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 | jcov.data.test.property=one -------------------------------------------------------------------------------- /plugins/data_coverage/test/openjdk/jcov/data/lib/TestStatusListener.java: -------------------------------------------------------------------------------- 1 | package openjdk.jcov.data.lib; 2 | 3 | import org.testng.ITestContext; 4 | import org.testng.ITestListener; 5 | import org.testng.ITestResult; 6 | 7 | public class TestStatusListener implements ITestListener { 8 | 9 | public static volatile boolean status = true; 10 | 11 | @Override 12 | public void onTestStart(ITestResult result) { } 13 | 14 | @Override 15 | public void onTestSuccess(ITestResult result) { } 16 | 17 | @Override 18 | public void onTestFailure(ITestResult result) { 19 | status = false; 20 | } 21 | 22 | @Override 23 | public void onTestSkipped(ITestResult result) { } 24 | 25 | @Override 26 | public void onTestFailedButWithinSuccessPercentage(ITestResult result) { } 27 | 28 | @Override 29 | public void onStart(ITestContext context) { status = true; } 30 | 31 | @Override 32 | public void onFinish(ITestContext context) { } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /plugins/simple_methods_anc/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /plugins/simple_methods_anc/src/openjdk/jcov/filter/simplemethods/EmptyMethods.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.filter.simplemethods; 26 | 27 | import org.objectweb.asm.tree.ClassNode; 28 | import org.objectweb.asm.tree.MethodNode; 29 | 30 | import java.util.function.BiPredicate; 31 | 32 | import static org.objectweb.asm.Opcodes.RETURN; 33 | 34 | public class EmptyMethods implements BiPredicate { 35 | @Override 36 | public boolean test(ClassNode node, MethodNode m) { 37 | int index = 0; 38 | int opCode = -1; 39 | //skip all instructions allowed to get values 40 | for(; index < m.instructions.size(); index++) { 41 | opCode = m.instructions.get(index).getOpcode(); 42 | if(opCode >=0) { 43 | if (!Utils.isSimpleInstruction(opCode)) { 44 | break; 45 | } 46 | } 47 | } 48 | //that should be a return 49 | return opCode == RETURN; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /plugins/simple_methods_anc/test/openjdk/jcov/filter/simplemethods/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package openjdk.jcov.filter.simplemethods; 26 | 27 | import org.objectweb.asm.ClassReader; 28 | import org.objectweb.asm.tree.ClassNode; 29 | import org.objectweb.asm.tree.MethodNode; 30 | 31 | import java.io.IOException; 32 | 33 | public class TestUtils { 34 | static ClassNode findTestClass(Class cls) throws IOException { 35 | ClassNode result = new ClassNode(); 36 | ClassReader reader = new ClassReader(cls.getClassLoader(). 37 | getResourceAsStream(cls.getName().replace('.','/') + ".class")); 38 | reader.accept(result, 0); 39 | return result; 40 | } 41 | 42 | static MethodNode findTestMethod(ClassNode cls, String methodSig) { 43 | for(Object mo: cls.methods) { 44 | MethodNode m = (MethodNode) mo; 45 | if((m.name + m.desc).equals(methodSig)) { 46 | return m; 47 | } 48 | } 49 | throw new IllegalStateException("Method does not exist: " + methodSig + " in class " + cls.name); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/classes/.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/ant/AllTasks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.ant; 26 | 27 | import org.apache.tools.ant.BuildException; 28 | import org.apache.tools.ant.Task; 29 | 30 | /** 31 | * 32 | * @author Andrey Titov 33 | */ 34 | public class AllTasks extends Task { 35 | 36 | @Override 37 | public void execute() throws BuildException { 38 | getProject().addTaskDefinition("grabber", Grabber.class); 39 | getProject().addTaskDefinition("grabber-manager", GrabberManager.class); 40 | getProject().addTaskDefinition("instrument", Instrument.class); 41 | getProject().addTaskDefinition("merge", Merge.class); 42 | getProject().addTaskDefinition("report", Report.class); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/ant/AntableSPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.ant; 26 | 27 | /** 28 | * 29 | * @author Andrey Titov 30 | */ 31 | public interface AntableSPI { 32 | 33 | /** 34 | * Allows to use this SPI through ANT wrappers 35 | * 36 | * @param attrName ANT attribute name. 37 | * @param attrValue Value of attribute to set. 38 | * @return False if this attribute name is not supported. If SPI returns 39 | * FALSE here - JCov will try to resolve setter method (setXXX where XXX is 40 | * attrName). If neither setter method exists neither handleAttribute() 41 | * accepts the attrName - BuildException would thrown. 42 | */ 43 | public boolean handleAttribute(String attrName, String attrValue); 44 | } 45 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/api/APIReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.api; 26 | 27 | import java.io.File; 28 | import java.io.IOException; 29 | import java.util.List; 30 | 31 | /** 32 | * Interface for parsing sig files 33 | * 34 | * @author Dmitry Fazunenko 35 | */ 36 | public interface APIReader { 37 | 38 | /** 39 | * Reads passed file. 40 | * 41 | * @param sigFile - file to parse 42 | * @return list of classes read 43 | * @throws IOException - in case of i/o problem 44 | * @throws FileFormatException - in case incorrect file format 45 | */ 46 | public List read(File sigFile) throws IOException, 47 | FileFormatException; 48 | } 49 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/api/APIWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.api; 26 | 27 | /** 28 | * Interface for creating sig files 29 | * 30 | * @author Dmitry Fazunenko 31 | */ 32 | public interface APIWriter { 33 | 34 | /** 35 | * Writes the entire API 36 | * 37 | * @param api 38 | */ 39 | public void writeAPI(API api); 40 | 41 | /** 42 | * Writes the ClassDescr 43 | * 44 | * @param cls 45 | */ 46 | public void writeClassDescr(ClassDescr cls); 47 | 48 | /** 49 | * Writes comment 50 | * 51 | * @param comment 52 | */ 53 | public void writeComment(String comment); 54 | 55 | public void close(); 56 | } 57 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/api/FileFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.api; 26 | 27 | /** 28 | * Exception signaling the problem with reading API sig file. 29 | * 30 | * @author Dmitry Fazunenko 31 | */ 32 | public class FileFormatException extends Exception { 33 | 34 | /** 35 | * Error happened at the particular line 36 | * 37 | * @param message - what's happened 38 | * @param lineNum - line # 39 | * @param fileName - file being parsed 40 | */ 41 | public FileFormatException(String message, int lineNum, String fileName) { 42 | this("Error parsing: " + fileName + " line# " + lineNum + ":" 43 | + message); 44 | } 45 | 46 | public FileFormatException(String message) { 47 | super(message); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/filter/AcceptAllSpi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.filter; 26 | 27 | /** 28 | * Implementation that returns filter accpeting everything. 29 | * 30 | * @author Dmitry Fazunenko 31 | */ 32 | public class AcceptAllSpi implements FilterSpi { 33 | 34 | public AcceptAllSpi() { 35 | } 36 | 37 | public MemberFilter getFilter() { 38 | return MemberFilter.ACCEPT_ALL; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/filter/FilterSpi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.filter; 26 | 27 | import com.sun.tdk.jcov.tools.ServiceProvider; 28 | 29 | /** 30 | * This interface defines the Service Provider Interface (SPI) for the 31 | * FilterFactory class.

32 | * 33 | * @author Dmitry Fazunenko 34 | * @author Sergey Borodin 35 | * 36 | */ 37 | public interface FilterSpi extends ServiceProvider { 38 | 39 | /** 40 | * Creates a class member filter. 41 | * 42 | * @return new filter, or null, if not supported 43 | */ 44 | public MemberFilter getFilter(); 45 | } 46 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/filter/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | *

MemberFilter Service Provider.

Interface for MemberFilter and 27 | * it's default implementations.

MemberFilter allows to select parts of 28 | * coverage data which should be processed in JCov tools.

29 | */ 30 | package com.sun.tdk.jcov.filter; -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBlockCatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * 32 | * @author Robert Field 33 | */ 34 | public class DataBlockCatch extends DataBlock { 35 | 36 | /** 37 | * Creates a new instance of DataBlockCatch 38 | */ 39 | public DataBlockCatch(int rootId) { 40 | super(rootId); 41 | } 42 | 43 | public DataBlockCatch(int rootId, int slot, boolean attached, long count) { 44 | super(rootId, slot, attached, count); 45 | } 46 | 47 | /** 48 | * XML Generation 49 | */ 50 | public String kind() { 51 | return XmlNames.CATCH; 52 | } 53 | 54 | DataBlockCatch(int rootId, DataInput in) throws IOException { 55 | super(rootId, in); 56 | } 57 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBlockFallThrough.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * DataBlockFallThrough 32 | * 33 | * @author Robert Field 34 | */ 35 | public class DataBlockFallThrough extends DataBlock { 36 | 37 | public DataBlockFallThrough(int rootId) { 38 | super(rootId); 39 | } 40 | 41 | public DataBlockFallThrough(int rootId, int slot, boolean attached, long count) { 42 | super(rootId, slot, attached, count); 43 | } 44 | 45 | /** 46 | * Does the previous block fall into this one? 47 | */ 48 | @Override 49 | public boolean isFallenInto() { 50 | return true; 51 | } 52 | 53 | /** 54 | * XML Generation 55 | */ 56 | public String kind() { 57 | return XmlNames.FALL; 58 | } 59 | 60 | DataBlockFallThrough(int rootId, DataInput in) throws IOException { 61 | super(rootId, in); 62 | } 63 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBlockMethEnter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * DataBlockMethEnter 32 | * 33 | * @author Robert Field 34 | */ 35 | public class DataBlockMethEnter extends DataBlock { 36 | 37 | public DataBlockMethEnter(int rootId) { 38 | super(rootId); 39 | } 40 | 41 | public DataBlockMethEnter(int rootId, int slot, boolean attached, long count) { 42 | super(rootId, slot, attached, count); 43 | } 44 | 45 | /** 46 | * Does the previous block fall into this one? Effectly yes, since this is 47 | * the first block. 48 | */ 49 | @Override 50 | public boolean isFallenInto() { 51 | return true; 52 | } 53 | 54 | /** 55 | * XML Generation 56 | */ 57 | public String kind() { 58 | return XmlNames.METHENTER; 59 | } 60 | 61 | DataBlockMethEnter(int rootId, DataInput in) throws IOException { 62 | super(rootId, in); 63 | } 64 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBlockTargetDefault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * DataBlockTargetDefault 32 | * 33 | * 34 | * @author Robert Field 35 | */ 36 | public class DataBlockTargetDefault extends DataBlockTarget { 37 | 38 | /** 39 | * Creates a new instance of DataBlockTargetDefault 40 | */ 41 | public DataBlockTargetDefault(int rootId) { 42 | super(rootId); 43 | } 44 | 45 | public DataBlockTargetDefault(int rootId, int slot, boolean attached, long count) { 46 | super(rootId, slot, attached, count); 47 | } 48 | 49 | /** 50 | * XML Generation 51 | */ 52 | public String kind() { 53 | return XmlNames.DEFAULT; 54 | } 55 | 56 | DataBlockTargetDefault(int rootId, DataInput in) throws IOException { 57 | super(rootId, in); 58 | } 59 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBlockTargetGoto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * DataBlockTargetGoto 32 | * 33 | * 34 | * @author Robert Field 35 | */ 36 | public class DataBlockTargetGoto extends DataBlockTarget { 37 | 38 | public DataBlockTargetGoto(int rootId) { 39 | super(rootId); 40 | } 41 | 42 | public DataBlockTargetGoto(int rootId, int slot, boolean attached, long count) { 43 | super(rootId, slot, attached, count); 44 | } 45 | 46 | /** 47 | * XML Generation 48 | */ 49 | public String kind() { 50 | return XmlNames.TG; 51 | } 52 | 53 | DataBlockTargetGoto(int rootId, DataInput in) throws IOException { 54 | super(rootId, in); 55 | } 56 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBranchCond.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * DataBranchCond 32 | * 33 | * 34 | * 35 | * @author Robert Field 36 | */ 37 | public class DataBranchCond extends DataBranch { 38 | 39 | public DataBranchCond(int rootId, int bciFromStart, int bciFromEnd) { 40 | super(rootId, bciFromStart, bciFromEnd); 41 | } 42 | 43 | DataBlockTarget branchTargetFallThrough() { 44 | return getBranchTargets().get(1); 45 | } 46 | 47 | DataBlockTarget branchTargetJump() { 48 | return getBranchTargets().get(0); 49 | } 50 | 51 | /** 52 | * XML Generation 53 | */ 54 | public String kind() { 55 | return XmlNames.BRANCH; 56 | } 57 | 58 | DataBranchCond(int rootId, DataInput in) throws IOException { 59 | super(rootId, in); 60 | } 61 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataBranchGoto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.IOException; 29 | 30 | /** 31 | * DataBranchGoto 32 | * 33 | * 34 | * @author Robert Field 35 | */ 36 | public class DataBranchGoto extends DataBranch { 37 | 38 | public DataBranchGoto(int rootId, int bciFromStart, int bciFromEnd) { 39 | super(rootId, bciFromStart, bciFromEnd); 40 | } 41 | 42 | DataBlockTarget branchTarget() { 43 | return getBranchTargets().get(0); 44 | } 45 | 46 | /** 47 | * XML Generation 48 | */ 49 | public String kind() { 50 | return XmlNames.GOTO; 51 | } 52 | 53 | DataBranchGoto(int rootId, DataInput in) throws IOException { 54 | super(rootId, in); 55 | } 56 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/DataExit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | import java.io.DataInput; 28 | import java.io.DataOutput; 29 | import java.io.IOException; 30 | import java.util.Iterator; 31 | 32 | /** 33 | * DataExit 34 | * 35 | * 36 | * @author Robert Field 37 | */ 38 | public abstract class DataExit extends LocationConcrete { 39 | 40 | DataExit(int rootId, int bciStart, int bciEnd) { 41 | super(rootId, bciStart, bciEnd); 42 | } 43 | 44 | public abstract Iterator getIterator(); 45 | 46 | void writeObject(DataOutput out) throws IOException { 47 | super.writeObject(out); 48 | } 49 | 50 | DataExit(int rootId, DataInput in) throws IOException { 51 | super(rootId, in); 52 | } 53 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/InstrumentationPlugin.java: -------------------------------------------------------------------------------- 1 | package com.sun.tdk.jcov.instrument; 2 | 3 | import java.nio.file.Path; 4 | 5 | public interface InstrumentationPlugin { 6 | /** 7 | * Called after all instrumentation is complete. 8 | * 9 | * @throws Exception should some 10 | */ 11 | void instrumentationComplete() throws Exception; 12 | 13 | /** 14 | * For the instrumented code to work independently (i.e. without adding additional classes to the classpath), some 15 | * classes can be "implanted" into the instrumented code. 16 | * 17 | * @return Path containing the classes to be implanted. Must be in a form which can be added to Java classpath. 18 | */ 19 | //TODO perhaps this can return a list of classes to be implanted 20 | Path runtime() throws Exception; 21 | 22 | /** 23 | * Name of a package which contains code, that will be called from the instrumented 24 | * code. Such package may need to be exported from a module. 25 | * 26 | * @return package name 27 | */ 28 | String collectorPackage(); 29 | } 30 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/Modifiers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument; 26 | 27 | public interface Modifiers { 28 | boolean isPublic(); 29 | 30 | boolean isPrivate(); 31 | 32 | boolean isProtected(); 33 | 34 | boolean isAbstract(); 35 | 36 | boolean isFinal(); 37 | 38 | boolean isSynthetic(); 39 | 40 | boolean isStatic(); 41 | 42 | boolean isInterface(); 43 | 44 | boolean isSuper(); 45 | 46 | boolean isNative(); 47 | 48 | boolean isDeprecated(); 49 | 50 | boolean isSynchronized(); 51 | 52 | boolean isVolatile(); 53 | 54 | boolean isBridge(); 55 | 56 | boolean isVarargs(); 57 | 58 | boolean isTransient(); 59 | 60 | boolean isStrict(); 61 | 62 | boolean isAnnotation(); 63 | 64 | boolean isEnum(); 65 | 66 | int access(); 67 | 68 | /** 69 | * This method is only a part of the contract to support deprecated methods. 70 | * @param code 71 | * @return 72 | * @see DataClass#hasModifier(int) 73 | * @see DataField#hasModifier(int) 74 | * @see DataMethod#hasModifier(int) 75 | */ 76 | @Deprecated 77 | boolean is(int code); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/asm/ASMInstrumentationPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.asm; 26 | 27 | import com.sun.tdk.jcov.instrument.InstrumentationPlugin; 28 | import org.objectweb.asm.MethodVisitor; 29 | 30 | /** 31 | * SPI class which allows to do additional instrumentation, in addition to instrumentation performed by JCov by default. 32 | * @author Alexander (Shura) Ilin. 33 | */ 34 | public interface ASMInstrumentationPlugin extends InstrumentationPlugin { 35 | /** 36 | * Supplies a MethodVisitor to perform additional instrumentation. 37 | * @return A valid method visitor. If no instrumentation needed, must return visitor argument. 38 | */ 39 | MethodVisitor methodVisitor(int access, String owner, String name, String desc, MethodVisitor visitor); 40 | } 41 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/asm/ASMUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.asm; 26 | 27 | import org.objectweb.asm.Opcodes; 28 | 29 | public class ASMUtils { 30 | /** 31 | * The ASM API version that should be used by jcov. 32 | */ 33 | public static final int ASM_API_VERSION = Opcodes.ASM9; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/asm/FieldAnnotationVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.asm; 26 | 27 | import com.sun.tdk.jcov.instrument.DataField; 28 | import com.sun.tdk.jcov.util.Utils; 29 | import org.objectweb.asm.AnnotationVisitor; 30 | import org.objectweb.asm.Attribute; 31 | import org.objectweb.asm.FieldVisitor; 32 | 33 | /** 34 | * Field visitor collecting runtime annotations 35 | * 36 | * @author Dmitry Fazunenko 37 | */ 38 | class FieldAnnotationVisitor extends FieldVisitor { 39 | 40 | final DataField field; 41 | final FieldVisitor fv; 42 | 43 | FieldAnnotationVisitor(final FieldVisitor fv, final DataField field) { 44 | super(ASMUtils.ASM_API_VERSION, fv); 45 | this.fv = fv; 46 | this.field = field; 47 | } 48 | 49 | public void visitAttribute(Attribute arg0) { 50 | fv.visitAttribute(arg0); 51 | } 52 | 53 | public void visitEnd() { 54 | fv.visitEnd(); 55 | } 56 | 57 | public AnnotationVisitor visitAnnotation(String anno, boolean b) { 58 | field.addAnnotation(anno); 59 | return fv.visitAnnotation(anno, b); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/asm/MethodAnnotationAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.asm; 26 | 27 | import com.sun.tdk.jcov.instrument.DataMethod; 28 | import com.sun.tdk.jcov.util.Utils; 29 | import org.objectweb.asm.AnnotationVisitor; 30 | import org.objectweb.asm.MethodVisitor; 31 | 32 | /** 33 | * Class that does nothing but collects runtime annotations 34 | * 35 | * @author Dmitry Fazunenko 36 | */ 37 | class MethodAnnotationAdapter extends MethodVisitor { 38 | 39 | final DataMethod meth; 40 | 41 | @Override 42 | public AnnotationVisitor visitAnnotation(String anno, boolean b) { 43 | meth.addAnnotation(anno); 44 | return super.visitAnnotation(anno, b); 45 | } 46 | 47 | MethodAnnotationAdapter(final MethodVisitor mv, 48 | final DataMethod method) { 49 | super(ASMUtils.ASM_API_VERSION, mv); 50 | this.meth = method; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/asm/OffsetLabel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.asm; 26 | 27 | import org.objectweb.asm.Label; 28 | 29 | /** 30 | * OffsetLabel 31 | * 32 | * @author Robert Field 33 | */ 34 | class OffsetLabel extends Label { 35 | 36 | int originalOffset; 37 | boolean realLabel; 38 | 39 | OffsetLabel(int originalOffset) { 40 | this.originalOffset = originalOffset; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | *

Package containing product structure information as well as it's coverage 27 | * data.

28 | */ 29 | package com.sun.tdk.jcov.instrument; 30 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/reader/DataAnnotatedStAX.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.reader; 26 | 27 | import com.sun.tdk.jcov.data.FileFormatException; 28 | import com.sun.tdk.jcov.instrument.DataAnnotated; 29 | import javax.xml.stream.XMLStreamException; 30 | import javax.xml.stream.XMLStreamReader; 31 | 32 | /** 33 | * 34 | * @author Sergey Borodin 35 | */ 36 | public class DataAnnotatedStAX implements Reader { 37 | 38 | private DataAnnotated anno; 39 | private XMLStreamReader parser; 40 | 41 | public void readData(Object dest) throws FileFormatException { 42 | anno = (DataAnnotated) dest; 43 | try { 44 | readData(); 45 | } catch (XMLStreamException ex) { 46 | throw new FileFormatException(ex); 47 | } 48 | } 49 | 50 | void readData() throws XMLStreamException { 51 | } 52 | 53 | public void setReaderFactory(ReaderFactory r) { 54 | parser = ((ReaderFactoryStAX) r).parser; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/reader/DataExitSimpleStAX.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.reader; 26 | 27 | import com.sun.tdk.jcov.data.FileFormatException; 28 | import javax.xml.stream.XMLStreamException; 29 | import javax.xml.stream.XMLStreamReader; 30 | 31 | /** 32 | * 33 | * @author Sergey Borodin 34 | */ 35 | public class DataExitSimpleStAX implements Reader { 36 | 37 | private XMLStreamReader parser; 38 | 39 | public void readData(Object dest) throws FileFormatException { 40 | try { 41 | readData(); 42 | } catch (XMLStreamException ex) { 43 | throw new FileFormatException(ex); 44 | } 45 | } 46 | 47 | void readData() throws XMLStreamException { 48 | // super.readDataFrom(parser, refs, mode); 49 | parser.nextTag(); //end exit 50 | } 51 | 52 | public void setReaderFactory(ReaderFactory r) { 53 | parser = ((ReaderFactoryStAX) r).parser; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/reader/Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.reader; 26 | 27 | import com.sun.tdk.jcov.data.FileFormatException; 28 | 29 | /** 30 | * 31 | * @author Sergey Borodin 32 | */ 33 | public interface Reader { 34 | 35 | public void readData(Object dest) throws FileFormatException; 36 | 37 | public void setReaderFactory(ReaderFactory r); 38 | } 39 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/reader/ReaderFactoryStAX.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.reader; 26 | 27 | import com.sun.tdk.jcov.data.FileFormatException; 28 | import java.io.InputStream; 29 | import javax.xml.stream.XMLInputFactory; 30 | import javax.xml.stream.XMLStreamException; 31 | import javax.xml.stream.XMLStreamReader; 32 | 33 | /** 34 | * 35 | * @author Sergey Borodin 36 | */ 37 | public class ReaderFactoryStAX extends ReaderFactory { 38 | 39 | protected XMLStreamReader parser; 40 | 41 | @Override 42 | void setDataSource(InputStream is) throws FileFormatException { 43 | XMLInputFactory factory = XMLInputFactory.newInstance(); 44 | 45 | try { 46 | factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); 47 | factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); 48 | parser = factory.createXMLStreamReader(is); 49 | } catch (XMLStreamException ex) { 50 | throw new FileFormatException(ex); 51 | } 52 | } 53 | 54 | @Override 55 | String getReadersSuffix() { 56 | return "StAX"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/instrument/reader/RootReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.reader; 26 | 27 | import com.sun.tdk.jcov.data.FileFormatException; 28 | 29 | /** 30 | * 31 | * @author Sergey Borodin 32 | */ 33 | public interface RootReader extends Reader { 34 | 35 | public void readHeader(Object dest) throws FileFormatException; 36 | } 37 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/logging.properties: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, 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 | 24 | handlers=com.sun.tdk.jcov.util.Utils$LoggerHandlerDelegator 25 | java.util.logging.ConsoleHandler.level=FINER 26 | java.util.logging.ConsoleHandler.formatter=com.sun.tdk.jcov.tools.LoggingFormatter 27 | java.util.logging.FileHandler.level=FINER 28 | java.util.logging.FileHandler.formatter=com.sun.tdk.jcov.tools.LoggingFormatter 29 | .level=WARNING -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | *

JCov tools accessible from CLI and by API.

JCov consists of a 27 | * number of tools used to prepare classes for coverage collection, collection 28 | * itself and post-collection proccessign. Every tool can be accessed from the 29 | * command line ("java -jar ") as well as from API.

It's 30 | * possible to create custom tools extending JCovCMDTool class.

31 | */ 32 | package com.sun.tdk.jcov; -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/processing/DataProcessorSPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.processing; 26 | 27 | import com.sun.tdk.jcov.tools.ServiceProvider; 28 | 29 | /** 30 | * This interface defines the Service Provider Interface (SPI) for the 31 | * DataProcessorFactory class.

32 | * 33 | * @author Dmitry Fazunenko 34 | */ 35 | public interface DataProcessorSPI extends ServiceProvider { 36 | 37 | /** 38 | * Creates a data processor. 39 | * 40 | * @return new data processor 41 | */ 42 | public DataProcessor getDataProcessor(); 43 | } 44 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/processing/DefaultDataProcessorSPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.processing; 26 | 27 | import com.sun.tdk.jcov.tools.EnvHandler; 28 | import com.sun.tdk.jcov.tools.EnvServiceProvider; 29 | 30 | /** 31 | * Provider of DataProcessor used by default. 32 | * 33 | * @author Dmitry Fazunenko 34 | */ 35 | public class DefaultDataProcessorSPI implements DataProcessorSPI, EnvServiceProvider { 36 | 37 | public DataProcessor getDataProcessor() { 38 | return new CombinerDataProcessor(); 39 | } 40 | 41 | public void extendEnvHandler(final EnvHandler handler) { 42 | } 43 | 44 | public int handleEnv(EnvHandler handler) { 45 | return 0; 46 | } 47 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/processing/ProcessingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.processing; 26 | 27 | /** 28 | * Exception signaling a problem happened while data processing. 29 | * 30 | * @author Dmitry Fazunenko 31 | */ 32 | public class ProcessingException extends Exception { 33 | 34 | public ProcessingException(String message) { 35 | super(message); 36 | } 37 | 38 | public ProcessingException(String message, Throwable cause) { 39 | super(message, cause); 40 | } 41 | 42 | public ProcessingException(Throwable cause) { 43 | super(cause); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/processing/StubSpi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.processing; 26 | 27 | import com.sun.tdk.jcov.tools.EnvHandler; 28 | 29 | /** 30 | * Stub implementation of DataProcessorFactorySpi 31 | * 32 | * @author Dmitry Fazunenko 33 | */ 34 | public class StubSpi implements DataProcessorSPI { 35 | 36 | /** 37 | * @return Data processor returning input data unmodified 38 | */ 39 | public DataProcessor getDataProcessor() { 40 | return DataProcessor.STUB; 41 | } 42 | 43 | public void extendEnvHandler(final EnvHandler handler) { 44 | } 45 | 46 | public int handleEnv(EnvHandler handler) { 47 | return 0; 48 | } 49 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/processing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | *

DataProcessor Service Provider

Interface for DataProcessor and 27 | * it's default implementations.

DataProcessor allows to pre-process 28 | * (modify) coverage structure before it's processing in tools.

29 | */ 30 | package com.sun.tdk.jcov.processing; -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/AncFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | 28 | import com.sun.tdk.jcov.instrument.DataBlock; 29 | import com.sun.tdk.jcov.instrument.DataClass; 30 | import com.sun.tdk.jcov.instrument.DataMethod; 31 | 32 | /** 33 | * @author Alexey Fedorchenko 34 | */ 35 | public interface AncFilter { 36 | 37 | public boolean accept(DataClass clz); 38 | 39 | public boolean accept(DataClass clz, DataMethod m); 40 | 41 | public boolean accept(DataMethod m, DataBlock b); 42 | 43 | public String getAncReason(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/AncFilterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | import java.util.Collection; 28 | 29 | /** 30 | * Implementations of this interface are responsible for mapping short names provided with {@code ancdf} options to 31 | * AncFilter instances. Instances of this interface are discovered through {@code ServiceLoader} API. 32 | */ 33 | public interface AncFilterFactory { 34 | /** 35 | * Creates an instance of {@code AncFilter} identified by a short name. 36 | * @param shortName 37 | * @return {@code AncFilter} or null, if {@code shortName} does not correspond to any filter supported by this factory. 38 | */ 39 | AncFilter instantiate(String shortName); 40 | 41 | /** 42 | * Instantiases all supported {@code AncFilter}s, which could be instanciated without additional information, 43 | * such as parameters of {@code ParameterizedAncFilter} 44 | * @return 45 | */ 46 | Collection instantiateAll(); 47 | } 48 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ParameterizedAncFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | /** 28 | * This interface represents an ability to pass a string parameter. Syntax of using default parameterized filters: 29 | *
java ... RepGen -ancdf <filter>:<parameter>
30 | */ 31 | public interface ParameterizedAncFilter extends AncFilter { 32 | /** 33 | * Sets filter parameter specified in the command line. 34 | * @param parameter 35 | * @throws Exception 36 | */ 37 | void setParameter(String parameter) throws Exception; 38 | } 39 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ReportGeneratorSPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | import com.sun.tdk.jcov.tools.ServiceProvider; 28 | 29 | /** 30 | * Service provider for creating custom reports 31 | * 32 | * @author Andrey Titov 33 | */ 34 | public interface ReportGeneratorSPI extends ServiceProvider { 35 | 36 | /** 37 | * @param formatName Name of the format specified by user (eg "-format 38 | * html") 39 | * @return custom report by name (eg "java -jar jcov.jar repgen -type myrep" 40 | * where "myrep" is name for a custom report) 41 | */ 42 | public ReportGenerator getReportGenerator(String formatName); 43 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | /** 28 | * @author Dmitry Fazunenko 29 | * @author Alexey Fedorchenko 30 | */ 31 | public interface Test { 32 | 33 | public String getTestOwner(); 34 | 35 | public String getTestName(); 36 | } 37 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ancfilters/CatchANCFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2018 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.instrument.DataBlock; 28 | import com.sun.tdk.jcov.instrument.DataClass; 29 | import com.sun.tdk.jcov.instrument.DataMethod; 30 | import com.sun.tdk.jcov.instrument.XmlNames; 31 | import com.sun.tdk.jcov.report.AncFilter; 32 | 33 | /** 34 | * @author Alexey Fedorchenko 35 | */ 36 | public class CatchANCFilter implements AncFilter { 37 | 38 | @Override 39 | public boolean accept(DataClass clz) { 40 | return false; 41 | } 42 | 43 | @Override 44 | public boolean accept(DataClass clz, DataMethod m) { 45 | return false; 46 | } 47 | 48 | @Override 49 | public boolean accept(DataMethod m, DataBlock b) { 50 | if (b.kind() != null && b.kind().equals(XmlNames.CATCH)){ 51 | return true; 52 | } 53 | return false; 54 | } 55 | 56 | @Override 57 | public String getAncReason() { 58 | return "Catch block filter"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ancfilters/DefaultAncFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.report.AncFilter; 28 | 29 | /** 30 | * @author Alexey Fedorchenko 31 | */ 32 | public interface DefaultAncFilter extends AncFilter { 33 | 34 | public String getFilterName(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ancfilters/DeprecatedANCFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.instrument.DataBlock; 28 | import com.sun.tdk.jcov.instrument.DataClass; 29 | import com.sun.tdk.jcov.instrument.DataMethod; 30 | import com.sun.tdk.jcov.report.AncFilter; 31 | 32 | /** 33 | * @author Alexey Fedorchenko 34 | */ 35 | public class DeprecatedANCFilter implements AncFilter { 36 | 37 | @Override 38 | public boolean accept(DataClass clz) { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean accept(DataClass clz, DataMethod m) { 44 | 45 | if (m.getModifiers().isDeprecated()){ 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | @Override 53 | public boolean accept(DataMethod m, DataBlock b) { 54 | return false; 55 | } 56 | 57 | @Override 58 | public String getAncReason() { 59 | return "Deprecated method filter"; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ancfilters/EmptyANCFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2018 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.instrument.DataBlock; 28 | import com.sun.tdk.jcov.instrument.DataClass; 29 | import com.sun.tdk.jcov.instrument.DataMethod; 30 | import com.sun.tdk.jcov.report.AncFilter; 31 | 32 | /** 33 | * @author Alexey Fedorchenko 34 | */ 35 | public class EmptyANCFilter implements AncFilter { 36 | 37 | @Override 38 | public boolean accept(DataClass clz) { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean accept(DataClass clz, DataMethod m) { 44 | 45 | if (m.getBlocks().size() == 1 46 | && m.getBlocks().get(0).startBCI() == 0 47 | && m.getBlocks().get(0).startBCI() == m.getBlocks().get(0).endBCI()){ 48 | return true; 49 | } 50 | 51 | return false; 52 | } 53 | 54 | @Override 55 | public boolean accept(DataMethod m, DataBlock b) { 56 | return false; 57 | } 58 | 59 | @Override 60 | public String getAncReason() { 61 | return "Empty method filter"; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ancfilters/SyntheticANCFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2022 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.instrument.DataBlock; 28 | import com.sun.tdk.jcov.instrument.DataClass; 29 | import com.sun.tdk.jcov.instrument.DataMethod; 30 | import com.sun.tdk.jcov.report.AncFilter; 31 | 32 | /** 33 | * @author Alexey Fedorchenko 34 | */ 35 | public class SyntheticANCFilter implements AncFilter { 36 | 37 | @Override 38 | public boolean accept(DataClass clz) { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean accept(DataClass clz, DataMethod m) { 44 | 45 | if (m.getModifiers().isSynthetic()){ 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | @Override 53 | public boolean accept(DataMethod m, DataBlock b) { 54 | return false; 55 | } 56 | 57 | @Override 58 | public String getAncReason() { 59 | return "Synthetic method filter"; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/ancfilters/ToStringANCFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2018 Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.instrument.DataBlock; 28 | import com.sun.tdk.jcov.instrument.DataClass; 29 | import com.sun.tdk.jcov.instrument.DataMethod; 30 | import com.sun.tdk.jcov.report.AncFilter; 31 | 32 | /** 33 | * @author Alexey Fedorchenko 34 | */ 35 | public class ToStringANCFilter implements AncFilter { 36 | 37 | @Override 38 | public boolean accept(DataClass clz) { 39 | return false; 40 | } 41 | 42 | @Override 43 | public boolean accept(DataClass clz, DataMethod m) { 44 | 45 | if (m.getName() != null 46 | && m.getName().equals("toString") 47 | && m.getVmSignature().startsWith("()")){ 48 | 49 | return true; 50 | } 51 | 52 | return false; 53 | } 54 | 55 | @Override 56 | public boolean accept(DataMethod m, DataBlock b) { 57 | return false; 58 | } 59 | 60 | @Override 61 | public String getAncReason() { 62 | return "toString() method filter"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/javap/JavapClassReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, 2024, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.javap; 26 | 27 | import java.io.PrintWriter; 28 | import java.util.NoSuchElementException; 29 | import java.util.spi.ToolProvider; 30 | 31 | import static java.util.spi.ToolProvider.findFirst; 32 | 33 | public class JavapClassReader { 34 | public static void read(String filePath, String jarPath, PrintWriter pw) { 35 | int rc = 0; 36 | try { 37 | ToolProvider javap = findFirst("javap").orElseThrow(); 38 | if (jarPath == null) { 39 | rc = javap.run(pw, new PrintWriter(System.err), "-c", "-p", filePath); 40 | } else { 41 | rc = javap.run(pw, new PrintWriter(System.err), "-c", "-p", "-classpath", jarPath, filePath); 42 | } 43 | } catch (NoSuchElementException ex) { 44 | System.err.println("Cannot find the javap tool"); 45 | } 46 | if (rc != 0) { 47 | System.err.println("Usage: java -cp jcov.jar com.sun.tdk.jcov.RepGen -javap path_to_classes " + 48 | "-o path_to_javap_output path_to_result.xml"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/javap/JavapCodeLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.javap; 26 | 27 | /** 28 | * Codeline of the javap output for classfile. This line could be covered or 29 | * not. 30 | * 31 | * @author Alexey Fedorchenko 32 | */ 33 | public class JavapCodeLine extends JavapLine { 34 | 35 | private int codeNumber; 36 | private boolean visited; 37 | 38 | public int getCodeNumber() { 39 | return codeNumber; 40 | } 41 | 42 | public void setCodeNumber(int number) { 43 | codeNumber = number; 44 | } 45 | 46 | public void setVisited(boolean value) { 47 | visited = value; 48 | } 49 | 50 | public boolean isVisited() { 51 | return visited; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/report/javap/JavapLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.javap; 26 | 27 | /** 28 | * Line of the javap output for classfile 29 | * 30 | * @author Alexey Fedorchenko 31 | */ 32 | public class JavapLine { 33 | 34 | private int lineNumber; 35 | private String line; 36 | 37 | public int getLineNumber() { 38 | return lineNumber; 39 | } 40 | 41 | public String getTextLine() { 42 | return line; 43 | } 44 | 45 | public void setLineNumber(int number) { 46 | lineNumber = number; 47 | } 48 | 49 | public void setTextLine(String textLine) { 50 | line = textLine; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/runtime/JCovSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.runtime; 26 | 27 | /** 28 | * 29 | * @author Leonid Mesnik 30 | */ 31 | public interface JCovSaver { 32 | 33 | public void saveResults(); 34 | } 35 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/runtime/SaverDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.runtime; 26 | 27 | /** 28 | * 29 | * @author Andrey Titov 30 | */ 31 | public interface SaverDecorator extends JCovSaver { 32 | 33 | public void init(JCovSaver saver); 34 | } 35 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/tools/JcovVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.tools; 26 | 27 | /** 28 | * 29 | * @author Andrey Titov 30 | */ 31 | public class JcovVersion { 32 | 33 | public static String jcovVersion = "DEV"; 34 | public static String jcovBuildNumber = "DEV"; 35 | public static String jcovMilestone = "DEV"; 36 | 37 | public static String getJcovVersion() { 38 | return "DEV"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/tools/OneElemIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.tools; 26 | 27 | import java.util.Iterator; 28 | import java.util.NoSuchElementException; 29 | 30 | /** 31 | * 32 | * @author Sergey Borodin 33 | */ 34 | public class OneElemIterator implements Iterator { 35 | 36 | private E e; 37 | private boolean hasNext; 38 | 39 | public OneElemIterator(E e) { 40 | this.e = e; 41 | hasNext = true; 42 | } 43 | 44 | public boolean hasNext() { 45 | return hasNext; 46 | } 47 | 48 | public E next() { 49 | if (hasNext) { 50 | hasNext = false; 51 | return e; 52 | } else { 53 | throw new NoSuchElementException(); 54 | } 55 | } 56 | 57 | public void remove() { 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/tools/ServiceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.tools; 26 | 27 | /** 28 | * 29 | * @author Andrey Titov 30 | */ 31 | public interface ServiceProvider { 32 | } -------------------------------------------------------------------------------- /src/classes/com/sun/tdk/jcov/tools/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | /** 26 | *

Utility classes for creating custom tools.

27 | */ 28 | package com.sun.tdk.jcov.tools; -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/instrument/instr/UserCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.instr; 26 | 27 | public class UserCode { 28 | private static int count = 0; 29 | public static void main(String[] args) { 30 | if(args[0].equals("-")) count--; 31 | else if(args[0].equals("+")) count++; 32 | System.out.println("User code is running."); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/instrument/jreinstr/Code.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.jreinstr; 26 | 27 | import javax.swing.JFrame; 28 | 29 | public class Code { 30 | public static void main(String[] args) { 31 | new JFrame(); 32 | System.out.println("User code has been executed."); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/instrument/plugin/FieldsClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.plugin; 26 | 27 | /** 28 | * This is a test class which is instrumented during the test. 29 | */ 30 | public class FieldsClass { 31 | int field1; 32 | String field2 = ""; 33 | 34 | public void setField1(int field1) { 35 | this.field1 = field1; 36 | } 37 | 38 | public void setField2(String field2) { 39 | this.field2 = field2; 40 | } 41 | 42 | public static void main(String[] args) { 43 | FieldsClass ac = new FieldsClass(); 44 | ac.field1 = 1; 45 | ac.field2 = "one"; 46 | ac.setField1(2); 47 | ac.setField2("two"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/instrument/plugin/jreinstr/Collect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.instrument.plugin.jreinstr; 26 | 27 | import java.lang.module.ModuleDescriptor; 28 | 29 | public class Collect { 30 | //this is called from the test to test that the necessary changes has been done by the instarumentation 31 | public static void main(String[] args) { 32 | Object.class.getModule().getDescriptor().exports().stream().filter(e -> !e.isQualified()) 33 | .map(ModuleDescriptor.Exports::source) 34 | .forEach(System.out::println); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/report/BasicUserCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | public class BasicUserCode { 28 | public static void main(String[] args) { 29 | if (args.length % 2 == 0) 30 | System.out.println("even"); 31 | else 32 | System.out.println("odd"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/report/RecordContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report; 26 | 27 | public class RecordContainer { 28 | public record Point(int x, int y) {} 29 | public static void main(String[] args) { 30 | System.out.println(new Point(0, 0).x); 31 | System.out.println(new Point(0, 0).y); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/unit/com/sun/tdk/jcov/report/ancfilters/BuiltInAncFiltersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. 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. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | package com.sun.tdk.jcov.report.ancfilters; 26 | 27 | import com.sun.tdk.jcov.report.AncFilter; 28 | import com.sun.tdk.jcov.report.AncFilterFactory; 29 | import org.testng.annotations.Test; 30 | 31 | import java.util.Collection; 32 | 33 | import static org.testng.Assert.assertTrue; 34 | 35 | public class BuiltInAncFiltersTest { 36 | static final AncFilterFactory factory = new BuiltInAncFilters(); 37 | @Test 38 | public void testInstantiate() { 39 | assertTrue(factory.instantiate("setter") instanceof SetterANCFilter); 40 | assertTrue(factory.instantiate("getter") instanceof GetterANCFilter); 41 | } 42 | @Test 43 | public void testInstantiateAll() { 44 | Collection filters = factory.instantiateAll(); 45 | assertTrue(filters.stream().anyMatch(f -> f instanceof CatchANCFilter)); 46 | assertTrue(filters.stream().anyMatch(f -> f instanceof DeprecatedANCFilter)); 47 | assertTrue(filters.stream().noneMatch(f -> f instanceof ListANCFilter)); 48 | } 49 | } 50 | --------------------------------------------------------------------------------