What is the difference between what you want to do here and "package
protected" that is standard in java (e.g. not using private, protected or
public modifiers) ?

regards,

Wim

2009/10/8 Matthew Adams <[email protected]>

> Hi all,
>
> Java has fused the concept of "namespace" and "component" in its
> concept of "package".  This results in having to mark public things
> that you really don't want public consumers to access.  .NET actually
> fixes this with its "protected internal" scope:  only code from within
> the current assembly can access the member scoped as protected
> internal.
>
> Now, I have a declare error statement attempting to achieve
> functionality similar to C#'s "protected internal" scope, whereby only
> code from within the current package is allowed to access the thing
> that is annotated with @ProtectedInternal.
>
> Here is my annotation & my declare error statement, but I'd like to
> make it more general, replacing "org.foo.model.*" with something more
> general that implies that access is disallowed from code that is
> outside the called/accessed element's package, that is, not in the
> annotated element's package.
>
> @Target( { ElementType.TYPE, ElementType.METHOD, ElementType.FIELD,
>                ElementType.CONSTRUCTOR })
> @Retention(RetentionPolicy.RUNTIME)
> public @interface ProtectedInternal {}
> ===============
> public aspect ProtectedInternalDeclareError {
>        declare error :
>                (!within(org.foo.model.*)) // TODO:  replace this hardcoding
> with
> something more general
>                        && (set(@ProtectedInternal * *)
>                                || get(@ProtectedInternal * *)
>                                || call(@ProtectedInternal * *(..))
>                                || call(* (@ProtectedInternal *..*).*(..))
>                                || call(@ProtectedInternal *.new(..))
>                                || call((@ProtectedInternal *).new(..))
>                )
>                : "The target constructor, method, or field is not designed
> for
> public consumption; access is disallowed.";
> }
>
> Help, anyone?
>
> Thanks,
> Matthew
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to