Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4110410A0C for ; Mon, 28 Jul 2014 07:45:19 +0000 (UTC) Received: (qmail 81468 invoked by uid 500); 28 Jul 2014 07:45:19 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 81423 invoked by uid 500); 28 Jul 2014 07:45:19 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 81390 invoked by uid 99); 28 Jul 2014 07:45:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2014 07:45:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2014 07:45:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6046023889E7; Mon, 28 Jul 2014 07:44:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1613904 - in /felix/trunk/scrplugin: generator/ generator/src/main/java/org/apache/felix/scrplugin/ generator/src/main/java/org/apache/felix/scrplugin/description/ generator/src/main/java/org/apache/felix/scrplugin/helper/ maven-scr-plugin... Date: Mon, 28 Jul 2014 07:44:53 -0000 To: commits@felix.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140728074453.6046023889E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Mon Jul 28 07:44:52 2014 New Revision: 1613904 URL: http://svn.apache.org/r1613904 Log: FELIX-4586 : A field must be volatile if methods are generated for a dynamic reference Modified: felix/trunk/scrplugin/generator/changelog.txt felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java felix/trunk/scrplugin/maven-scr-plugin/changelog.txt felix/trunk/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java felix/trunk/scrplugin/scrtask/changelog.txt Modified: felix/trunk/scrplugin/generator/changelog.txt URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/changelog.txt?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/generator/changelog.txt (original) +++ felix/trunk/scrplugin/generator/changelog.txt Mon Jul 28 07:44:52 2014 @@ -1,3 +1,11 @@ +Changes from 1.11.0 to 1.10.0 +---------------------------- +** Improvement + * [FELIX-4586] - A field must be volatile if methods are generated for a dynamic reference +** Bug + * [FELIX-4296] - Cannot deactivate service interface detection in DS annotations + + Changes from 1.10.0 to 1.9.0 ---------------------------- ** Improvement Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java (original) +++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/Options.java Mon Jul 28 07:44:52 2014 @@ -46,6 +46,9 @@ public class Options { /** Is this an incremental build? */ private boolean incremental = false; + /** Skip volatile check. */ + private boolean skipVolatileCheck = false; + /** * @see #setGenerateAccessors(boolean) * @return Whether accessor methods should be generated. @@ -174,4 +177,18 @@ public class Options { public void setIncremental(final boolean incremental) { this.incremental = incremental; } + + /** + * Should the check for volatile fields be skipped? + */ + public boolean isSkipVolatileCheck() { + return skipVolatileCheck; + } + + /** + * Set whether the check should be skipped + */ + public void setSkipVolatileCheck(final boolean skipVolatileCheck) { + this.skipVolatileCheck = skipVolatileCheck; + } } Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java (original) +++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java Mon Jul 28 07:44:52 2014 @@ -280,6 +280,9 @@ public class SCRDescriptorGenerator { this.project.getClassLoader(), this.project.getClassesDirectory(), this.logger); + // set a flag for validation + ref.setBindMethodCreated(createBind); + ref.setUnbindMethodCreated(createUnbind); } } } Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java (original) +++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ReferenceDescription.java Mon Jul 28 07:44:52 2014 @@ -62,6 +62,9 @@ public class ReferenceDescription extend private String unbind; private String updated; + private boolean bindMethodCreated = false; + private boolean unbindMethodCreated = false; + public ReferenceDescription(final ScannedAnnotation annotation) { super(annotation); } @@ -154,6 +157,23 @@ public class ReferenceDescription extend this.field = field; } + public boolean isBindMethodCreated() { + return bindMethodCreated; + } + + public void setBindMethodCreated(final boolean bindMethodCreated) { + this.bindMethodCreated = bindMethodCreated; + } + + public boolean isUnbindMethodCreated() { + return unbindMethodCreated; + } + + public void setUnbindMethodCreated(final boolean unbindMethodCreated) { + this.unbindMethodCreated = unbindMethodCreated; + } + + @Override public String toString() { return "ReferenceDescription [name=" + name + ", interfaceName=" @@ -165,6 +185,15 @@ public class ReferenceDescription extend + "]"; } + + @Override + public String getIdentifier() { + if ( this.getField() != null ) { + return super.getIdentifier() + "(" + this.getField().getName() + ")"; + } + return super.getIdentifier(); + } + @Override public AbstractDescription clone() { final ReferenceDescription cd = new ReferenceDescription(this.annotation); @@ -179,6 +208,8 @@ public class ReferenceDescription extend cd.setBind(this.getBind()); cd.setUnbind(this.getUnbind()); cd.setUpdated(this.getUpdated()); + cd.setBindMethodCreated(this.isBindMethodCreated()); + cd.setUnbindMethodCreated(this.isUnbindMethodCreated()); return cd; } Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java (original) +++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/Validator.java Mon Jul 28 07:44:52 2014 @@ -480,7 +480,7 @@ public class Validator { if ( bindName != null ) { bindName = this.validateMethod(ref, bindName, componentIsAbstract); if ( bindName == null && ref.getField() != null ) { - iLog.addError("Something went wrong: " + canGenerate + " - " + this.options.isGenerateAccessors() + " - " + ref.getCardinality(), ref.getField().getName()); + this.logError(ref, "Something went wrong: " + canGenerate + " - " + this.options.isGenerateAccessors() + " - " + ref.getCardinality()); } } else { bindName = "bind" + Character.toUpperCase(ref.getName().charAt(0)) + ref.getName().substring(1); @@ -491,10 +491,32 @@ public class Validator { unbindName = "unbind" + Character.toUpperCase(ref.getName().charAt(0)) + ref.getName().substring(1); } + // check for volatile on dynamic field reference with cardinality unary + if ( !this.options.isSkipVolatileCheck() ) { + if ( ref.getField() != null + && (ref.getCardinality() == ReferenceCardinality.OPTIONAL_UNARY || ref.getCardinality() == ReferenceCardinality.MANDATORY_UNARY) + && ref.getPolicy() == ReferencePolicy.DYNAMIC ) { + final boolean fieldIsVolatile = Modifier.isVolatile(ref.getField().getModifiers()); + + if ( ref.isBindMethodCreated() || ref.isUnbindMethodCreated() ) { + // field must be volatile + if (!fieldIsVolatile) { + this.logError(ref, "Dynamic field must be declared volatile for unary references"); + } + } else { + // field should be volatile + if (!fieldIsVolatile) { + this.logError(ref, "Dynamic field should be declared volatile for unary references"); + } + } + } + } + if (iLog.getNumberOfErrors() == currentIssueCount) { ref.setBind(bindName); ref.setUnbind(unbindName); } + } else { ref.setBind(null); ref.setUnbind(null); Modified: felix/trunk/scrplugin/maven-scr-plugin/changelog.txt URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/maven-scr-plugin/changelog.txt?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/maven-scr-plugin/changelog.txt (original) +++ felix/trunk/scrplugin/maven-scr-plugin/changelog.txt Mon Jul 28 07:44:52 2014 @@ -1,3 +1,12 @@ +Changes from 1.18.0 to 1.17.0 +----------------------------- +** Improvement + * [FELIX-4586] - A field must be volatile if methods are generated for a dynamic reference + * [FELIX-4530] - Revisit setting the default output to target/classes +** Bug + * [FELIX-4296] - Cannot deactivate service interface detection in DS annotations + + Changes from 1.17.0 to 1.16.0 ----------------------------- ** Improvement Modified: felix/trunk/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java (original) +++ felix/trunk/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java Mon Jul 28 07:44:52 2014 @@ -164,6 +164,13 @@ public class SCRDescriptorMojo extends A private boolean scanClasses; /** + * Skip volatile check for fields. + * + * @parameter default-value="false" + */ + private boolean skipVolatileCheck; + + /** * @component */ private BuildContext buildContext; @@ -202,6 +209,7 @@ public class SCRDescriptorMojo extends A options.setProperties(properties); options.setSpecVersion(SpecVersion.fromName(specVersion)); options.setIncremental(this.buildContext.isIncremental()); + options.setSkipVolatileCheck(this.skipVolatileCheck); if ( specVersion != null && options.getSpecVersion() == null ) { throw new MojoExecutionException("Unknown spec version specified: " + specVersion); Modified: felix/trunk/scrplugin/scrtask/changelog.txt URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/scrtask/changelog.txt?rev=1613904&r1=1613903&r2=1613904&view=diff ============================================================================== --- felix/trunk/scrplugin/scrtask/changelog.txt (original) +++ felix/trunk/scrplugin/scrtask/changelog.txt Mon Jul 28 07:44:52 2014 @@ -1,3 +1,11 @@ +Changes from 1.12.0 to 1.11.0 +----------------------------- +** Improvement + * [FELIX-4586] - A field must be volatile if methods are generated for a dynamic reference +** Bug + * [FELIX-4296] - Cannot deactivate service interface detection in DS annotations + + Changes from 1.11.0 to 1.10.0 ----------------------------- ** Improvement