When does the constructor of a Scala user-defined annotation class gets executed?In Scala, how do you define a local parameter in the primary constructor of a class?scala: How to get the class in its own constructorWhere does Scala look for implicits?Annotation with User Defined classUser defined and default constructor?Functions in a Scala constructor don't get calledHow to enforce scala macro annotation constraints on annotated classes?Initialization of a C++ Struct with a user defined constructorHow to define val inside class constructor in ScalaHow to get the extended classpath of a Scala-macro-annotated class or object, in the macro?

How to stabilise the bicycle seatpost and saddle when it is all the way up?

My research paper filed as a patent in China by my Chinese supervisor without me as inventor

Does an oscilloscope subtract voltages as phasors?

Uncovering the Accelerated Dragon opening

Do ibuprofen or paracetamol cause hearing loss?

A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?

What would be the seasonal impact on the indoor climate of a giant dome habitation?

Can the UK veto its own extension request?

Seized engine due to being run without oil

How are chord ratios developed exactly?

How do I find an ADC circuit's bandwidth experimentally?

Is there a star over my head?

Is low emotional intelligence associated with right-wing and prejudiced attitudes?

Which ping implementation is Cygwin using?

How to help my 2.5-year-old daughter take her medicine when she refuses to?

Can I disable a battery powered device by reversing half of its batteries?

Can I toggle Do Not Disturb on/off on my Mac as easily as I can on my iPhone?

Why aren't tangent spaces simply defined as vector spaces with same dimension as the manifold?

Linear Programming with additional "if-then"/"Default to zero" constraints?

Why would "an mule" be used instead of "a mule"?

Job offer without any details but asking me to withdraw other applications - is it normal?

Is there a reliable way to hide/convey a message in vocal expressions (speech, song,...)

Do Milankovitch Cycles fully explain climate change?

Why did it become so much more expensive to start a university?



When does the constructor of a Scala user-defined annotation class gets executed?


In Scala, how do you define a local parameter in the primary constructor of a class?scala: How to get the class in its own constructorWhere does Scala look for implicits?Annotation with User Defined classUser defined and default constructor?Functions in a Scala constructor don't get calledHow to enforce scala macro annotation constraints on annotated classes?Initialization of a C++ Struct with a user defined constructorHow to define val inside class constructor in ScalaHow to get the extended classpath of a Scala-macro-annotated class or object, in the macro?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I defined a Scala class MyAnnotation, used to annotate certain classes within my program:



case class MyAnnotation() extends scala.annotation.StaticAnnotation 
println("MyAnnotation initialized") // doesn't get printed



Which is used in the following way:



@MyAnnotation()
class MyClass()
...



However, when I instantiate the MyClass class, the constructor of MyAnnotation doesn't get executed. I.e., the println does not happen.



val x = new MyClass()
// nothing gets printed


Sumarized: is there any way to provide a constructor to a user-defined annotation class that gets executed when another class annotated with that annotation is instantiated?










share|improve this question



















  • 1





    Answer is NO.

    – talex
    Mar 28 at 9:37











  • Technically, the answer is yes: make it a macro annotation (docs.scala-lang.org/overviews/macros/annotations.html) and transform the constructor(s) of the annotated class in the macro. Whether this is code you want to write and maintain, is your decision. I certainly don't, which is why this isn't an answer :)

    – Alexey Romanov
    Mar 28 at 17:45

















0















I defined a Scala class MyAnnotation, used to annotate certain classes within my program:



case class MyAnnotation() extends scala.annotation.StaticAnnotation 
println("MyAnnotation initialized") // doesn't get printed



Which is used in the following way:



@MyAnnotation()
class MyClass()
...



However, when I instantiate the MyClass class, the constructor of MyAnnotation doesn't get executed. I.e., the println does not happen.



val x = new MyClass()
// nothing gets printed


Sumarized: is there any way to provide a constructor to a user-defined annotation class that gets executed when another class annotated with that annotation is instantiated?










share|improve this question



















  • 1





    Answer is NO.

    – talex
    Mar 28 at 9:37











  • Technically, the answer is yes: make it a macro annotation (docs.scala-lang.org/overviews/macros/annotations.html) and transform the constructor(s) of the annotated class in the macro. Whether this is code you want to write and maintain, is your decision. I certainly don't, which is why this isn't an answer :)

    – Alexey Romanov
    Mar 28 at 17:45













0












0








0


1






I defined a Scala class MyAnnotation, used to annotate certain classes within my program:



case class MyAnnotation() extends scala.annotation.StaticAnnotation 
println("MyAnnotation initialized") // doesn't get printed



Which is used in the following way:



@MyAnnotation()
class MyClass()
...



However, when I instantiate the MyClass class, the constructor of MyAnnotation doesn't get executed. I.e., the println does not happen.



val x = new MyClass()
// nothing gets printed


Sumarized: is there any way to provide a constructor to a user-defined annotation class that gets executed when another class annotated with that annotation is instantiated?










share|improve this question














I defined a Scala class MyAnnotation, used to annotate certain classes within my program:



case class MyAnnotation() extends scala.annotation.StaticAnnotation 
println("MyAnnotation initialized") // doesn't get printed



Which is used in the following way:



@MyAnnotation()
class MyClass()
...



However, when I instantiate the MyClass class, the constructor of MyAnnotation doesn't get executed. I.e., the println does not happen.



val x = new MyClass()
// nothing gets printed


Sumarized: is there any way to provide a constructor to a user-defined annotation class that gets executed when another class annotated with that annotation is instantiated?







scala constructor annotations






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 9:28









MaartenMaarten

956 bronze badges




956 bronze badges










  • 1





    Answer is NO.

    – talex
    Mar 28 at 9:37











  • Technically, the answer is yes: make it a macro annotation (docs.scala-lang.org/overviews/macros/annotations.html) and transform the constructor(s) of the annotated class in the macro. Whether this is code you want to write and maintain, is your decision. I certainly don't, which is why this isn't an answer :)

    – Alexey Romanov
    Mar 28 at 17:45












  • 1





    Answer is NO.

    – talex
    Mar 28 at 9:37











  • Technically, the answer is yes: make it a macro annotation (docs.scala-lang.org/overviews/macros/annotations.html) and transform the constructor(s) of the annotated class in the macro. Whether this is code you want to write and maintain, is your decision. I certainly don't, which is why this isn't an answer :)

    – Alexey Romanov
    Mar 28 at 17:45







1




1





Answer is NO.

– talex
Mar 28 at 9:37





Answer is NO.

– talex
Mar 28 at 9:37













Technically, the answer is yes: make it a macro annotation (docs.scala-lang.org/overviews/macros/annotations.html) and transform the constructor(s) of the annotated class in the macro. Whether this is code you want to write and maintain, is your decision. I certainly don't, which is why this isn't an answer :)

– Alexey Romanov
Mar 28 at 17:45





Technically, the answer is yes: make it a macro annotation (docs.scala-lang.org/overviews/macros/annotations.html) and transform the constructor(s) of the annotated class in the macro. Whether this is code you want to write and maintain, is your decision. I certainly don't, which is why this isn't an answer :)

– Alexey Romanov
Mar 28 at 17:45












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55394127%2fwhen-does-the-constructor-of-a-scala-user-defined-annotation-class-gets-executed%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55394127%2fwhen-does-the-constructor-of-a-scala-user-defined-annotation-class-gets-executed%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해