Java Annotations in Raku or my @annotation is role; - Mikhail Khorkov raku-advent.blog/2021/12/…
πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/liztormato
πŸ“…︎ Dec 10 2021
🚨︎ report
Java Spring Boot Without Annotations

Hello Everyone! First of all sorry for my english!

I want to create a Spring boot rest api without using annotations. Basically I want to get routes dynamically from a control panel from web browser and after that I want add them to the controller while the program is running. I tried to do that with annotations but it has to be static constant strings that is impossible to do I guess in runtime? What can I do instead?

πŸ‘︎ 7
πŸ’¬︎
πŸ“…︎ Sep 24 2021
🚨︎ report
Are Java developers obsessed with annotations?

Annotations are very common in enterprise Java software. Typical frameworks like Spring and Hibernate bring lots and lots of annotations. Sometimes they are really practical, but in many cases they introduce new problems:

Expression Languages

To express complex cases so called "expression languages" like Spring EL or Jakarta EL are required. That introduces unnecessary complexity in tooling and forces everyone to learn those languages, altough Java is a powerful language with way more possibilities. Depending on the tool support EL strings are good places for bugs to hide!

Code Pollution

Sometimes a single annotation is not enough and several annotations must be nested, what can be a large block of meta-information in your code:

@Entity
@Table(
    name = "author",
    indexes =  @Index(
        name = "idx_author_first_last_name",
        columnList = "first_name, last_name",
        unique = false
    )
)
public static class Author {

Depending on the project annotation meta code can be a big part of class almost hiding the actual code.

Not Comprehensible

Annotations are just meta data and the actual effect happens somewhere else in a framework or an annotation processor. It is not (always) possible to navigate to the code that performs the logic linked to the annotation.

May fail silently

Annotation processing could not be executed silently. Imagine an authorization mechanism base on annotations which is ineffective due to an configuration error!

Dificult to extend

Annotation based programming is not as easily extensible as usual code. While writing a custom annotation is relative simple, the logic for annotation processing and integration into a framework might be compolicated. It is for example a lot harder to write a custom Bean Validation annotation plus the validation logic, than to use plain Java code with the Spring Validator.

Limited Compiler Support

The compiler is very limited in checking whether your annotations work as intended. In the end annotations are a language in a language without good compiler support.

Time to rethink

I guess the reason for the annotation obsession is that Java was very limited to create nice APIs before functions were int

... keep reading on reddit ➑

πŸ‘︎ 56
πŸ’¬︎
πŸ‘€︎ u/cryptos6
πŸ“…︎ Jul 29 2021
🚨︎ report
Google recently released Kotlin Symbol Processing (KSP), a new tool to do metaprogramming on Kotlin. KSP is a lightweight alternative to both Java Annotation Processors and Kotlin Compiler plugins. In this talk Jeffrey and Ting-Yuan describe why they built KSP and with which design pr principles. youtu.be/bv-VyGM3HCY
πŸ‘︎ 30
πŸ’¬︎
πŸ‘€︎ u/Anisim_1
πŸ“…︎ Nov 02 2021
🚨︎ report
java.lang.ClassNotFoundException: org/jetbrains/annotations/ApiStatus$ScheduledForRemoval error? (1.17.1)

https://pastebin.com/39R0UUvp

Crashes before the MC loading window even shows up. From testing it seems like something is trying to call sodium, but I can't figure out what. I have tried removing all sodium related mods I could find, but then it still crashed with a similar error message, this is the log when I tried to add in sodiumand sodium related mods.

modlist :

https://pastebin.com/dEgk3Br5

edit : after another hour of testing, it looks like the crash has nothing to do with the log and fabric is crashing because of something ELSE that it doesn't log. For instance these are the bottom 3 lines of another log

[09:02:07] [Render thread/INFO]: A config file was found, loading it..

[09:02:07] [Render thread/INFO]: Successfully loaded config file.

[09:02:07] [Render thread/INFO]: [STDOUT]: Loading TRansliterationLib

these don't indicate to me any errors, crashes, or exceptions and GD launcher didn't even say MC crashed, it just never bothered to open. (I can tell it did crash though because GDlauncher has a loading circle that stops spinning and shortly after when I right click on the instance there is no longer a kill option)

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/temmiesayshoi
πŸ“…︎ Oct 10 2021
🚨︎ report
Where/how do I find spring/java annotations?

Hi I am learning spring and lot of times there are annotations being used. Experienced programmers just mention, "ah use this annotation here". How do I know of all the annotations? what they do ... etc. etc.

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/pappugulal
πŸ“…︎ Aug 28 2021
🚨︎ report
java hibernate column annotation issue

Hello, i have a simple single entity class with secondaryTable.But i'm having issue with the column annotation that doesn't redirect the variable to the specified table, they stay in the entity where they are declared.

//CLient is an entity
@Entity
//Rename the entity to clients with an 's'
@Table(name="clients")
//add a 'preferences' table
@SecondaryTable(name="preferences",
        //1 to 1 relationship between 'identifiant' FROM Client and
        //identifiant_client FROM Preferences
        pkJoinColumns=@PrimaryKeyJoinColumn(name="identifiant_client"),
        //name of the constraint
        foreignKey=@ForeignKey(name="fk_preferences_clients")
)
/*
CREATE TABLE  "PREFERENCES"
   (	"IDENTIFIANT_CLIENT" NUMBER(19,0) NOT NULL ENABLE,
	 PRIMARY KEY ("IDENTIFIANT_CLIENT") ENABLE,
	 CONSTRAINT "FK_PREFERENCES_CLIENTS" FOREIGN KEY ("IDENTIFIANT_CLIENT")
	  REFERENCES  "CLIENTS" ("IDENTIFIANT") ENABLE
   )
/
 */

public class Client {
    private String name;
    private String surname;
    private String email;
    private String passWord;
    private Long identifiant;

    @Column(name="theme", table="preferences")
    private String theme;
    @Column(name="language", table="preferences")
    private String language;


    public Client() {
        //
    }

    protected void setName(String name) {
        this.name = name;
    }
    protected void setSurname(String surname) {
        this.surname = surname;
    }
    protected void setEmail(String email) {
        this.email = email;
    }
    protected void setPassWord(String passWord) {
        this.passWord = passWord;
    }
    protected String getName() {
        return name;
    }
    protected String getSurname() {
        return surname;
    }
    protected String getEmail() {
        return email;
    }
    protected String getPassWord() {
        return passWord;
    }

    public String getLanguage() {
        return language;
    }
    public void setLanguage(String language) {
        this.language = language;
    }
    public String getTheme() {
        return theme;
    }
    public void setTheme(String theme) {
        this.theme = theme;
    }


    public void setIdentifia
... keep reading on reddit ➑

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/popey123
πŸ“…︎ Sep 20 2021
🚨︎ report
ELI5: What is Annotations in Java spring framework?

So I've searched the whole sub and there's no such question asked unfortunately..

Anyone can ELI5 me the annotations in spring framework in Java? Thanks

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/comeditime
πŸ“…︎ Aug 01 2021
🚨︎ report
Wrong indentation after annotation, Java.

Basically what title says, intellij adds unnecessary indentation after any annotation.
How do i fix it?

https://preview.redd.it/zb4fuliamd671.png?width=284&format=png&auto=webp&s=f6efb0599f45586cc87607fa466973095293841d

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/red_kizuen
πŸ“…︎ Jun 20 2021
🚨︎ report
Java Bean Validation Extension - Additional @Annotations for Bean Validation

A few years ago, I was using JSR-380 extensively on my projects, and I decided to extend the functionality with additional validation annotations, so I've written JVBE. The library was then referenced by the official Jakarta Bean Validation site.

Fast forward today, the code has been recently cleaned up (by a nice contributor) and a new release was performed. Feedback is as always greatly appreciated.

πŸ‘︎ 19
πŸ’¬︎
πŸ‘€︎ u/nomemory
πŸ“…︎ Apr 20 2021
🚨︎ report
To those familiar with the Java Immutables Annotations Framework...

Is it possible to have the generated Immutable file have the exact same name as the base file?

I can use style(typeImmutable = '*'), but this will give me the error:

Generated source file name colission. Attempted to override already generated file

Is what I want to do even possible?

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ May 11 2021
🚨︎ report
Literature on Java Annotation Processors

Hey all!

I've been looking for actual full fledged literature on Java Annotation Processors.

I need to get into how they work and how they're implemented and blog posts are usually lackluster. Same for the documentation, it explains them and it doesn't...

I'm curious what kind of resources are out there.

Note: blogs are allowed, they just need to be actually complete.
For reference, a bit more complete than https://blog.frankel.ch/introductory-guide-annotation-processor/

πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/CritJongUn
πŸ“…︎ Feb 03 2021
🚨︎ report
Java annotations

I would like to better understand the usefulness of Java annotations and their applications, what is it used for and how is it useful in JPA or Spring Web for example?

πŸ‘︎ 28
πŸ’¬︎
πŸ‘€︎ u/tiberio13
πŸ“…︎ Nov 27 2020
🚨︎ report
Java EE and Annotations

Hi there,

I have joined the development of an old JavaEE (2016 or older) project. The structure seems like the original devs hadn't had much experienced with JavaEE or the code is just vastly outdated, idk.

They used tomcat7, java8, servlets, hibernate without JPA, google guice for dependency injection and not CDI. It is not a Spring application .

What I wonder about the code is, why they did not even use the typical annotations on classes or methods like @GET, @INJECT or @Transactional, @Entity etc.

In every documentation or tutorial they are part of it nowadays. Where they introduced in JavaEE at a certain version?

What would happen in a modern jakarta Web Applikation when you dont write the @GET of @inject etc. annotations? Do they even have an effect on the compilation or are they just there to make the code more understandable? What happens when one is not using them?

Also, they did use hibernate but not jpa. They had a hibernate mapping file and classes for the entities but even these were not annotated.

And they had DTO classes for every entity but these are used nowhere..

I am even not sure they used EJBs. The entity classes look like simple POJOs.

Also they just used tomcat 7 as web container. But wasnt this version not supporting EJBs? TomEE fits better I guess.

I would really like to migrate to jakarta and hopfully microservices but it seems I need to understand first what actually is going on there and what is redundant.

Any suggestions on how to proceed?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/m3phista
πŸ“…︎ Jan 22 2021
🚨︎ report
Passing Java classes as arguments to annotation

I tried to create a test suite with Kotlin that runs Java test classes. As far as I see, I followed the Android guides to a T: https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests#test-suites

But for my @ Suite annotation, I am getting the error "An annotation argument must be a compile-time constant" and "Unresolved reference" errors for the test classes even though they are being imported.

@Suite.SuiteClasses( TestA::class, TestB::class, TestC::class, TestD::class )

Is this because they are Java files and they can't be converted to KClass like this? How can I pass in Java files?

πŸ‘︎ 5
πŸ’¬︎
πŸ“…︎ Aug 27 2020
🚨︎ report
When will Java include annotations/keywords for getters and setters?

Writing getters and setters is kind of dumb, like the compiler should do this for us. We shouldn’t have to depend on IDE’s or Lombok or human typists to do this kind of busywork.

... not that I think encapsulation should happen at field level, but if we’re going to have non-public fields, we might as well have Java generate good code for getters and setters out of the box.

πŸ‘︎ 79
πŸ’¬︎
πŸ‘€︎ u/mcandre
πŸ“…︎ Dec 07 2018
🚨︎ report
Swagger java annotations in action medium.com/@domrevigor/ge…
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/Viggin543
πŸ“…︎ Jun 20 2020
🚨︎ report
"No language before or after Java ever abused annotations as much as Java" blog.jooq.org/2015/04/15/…
πŸ‘︎ 208
πŸ’¬︎
πŸ‘€︎ u/lukaseder
πŸ“…︎ Apr 15 2015
🚨︎ report
Kotlin-Compile-Testing: A library for testing Kotlin and Java annotation processors, compiler plugins and code generation github.com/tschuchortdev/…
πŸ‘︎ 27
πŸ’¬︎
πŸ“…︎ Sep 16 2019
🚨︎ report
[Java] How do I inject some instantiated object in a class through annotation?

I am trying to understand how lombok's @Slf4j annotation manages to inject a static instance of the org.slf4j.Logger class in the annotated classes. The similar effect without the annotation would be,

class ClassName {
    private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ClassName.class);
}

I am trying to do something similar. Imagine I create some custom annotation @MyAnnotation, and upon using that it would inject a static instance of SomeCustomClass. However I am not sure where to start. I looked through the source codes of lombok slf4j and apache slf4j, but I feel i am lacking some basic concepts (most probably AOP stuff, I am not familiar with it yet), because of which I can't piece things together.

So, I would like to know how I should proceed. What concepts would help me achieving this and if someone can link to some example/tutorial, that would be great.

> I would ask StackOverflow, but I'm sure some wise overlord would close it and mark as duplicate linking it to some unrelated question. So, I am relying on still humane reddit community.

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/invictus08
πŸ“…︎ Oct 31 2019
🚨︎ report
Kotlin-Compile-Testing: A library for testing Kotlin and Java annotation processors, compiler plugins and code generation github.com/tschuchortdev/…
πŸ‘︎ 14
πŸ’¬︎
πŸ“…︎ Sep 16 2019
🚨︎ report
10 Spring Core Annotations for Java Developers java67.com/2018/11/top-10…
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/javinpaul
πŸ“…︎ Nov 24 2018
🚨︎ report
What would be some nice feature I could do with annotation processor in Kotlin/Java

Hello guys. I learned how the annotation processor works and I'm starting to call it a mini hobby :P. But I haven't really made a true case, I just refactored some unnecessary code. So my question for you, where would you use the annotation processor?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/stavro24496
πŸ“…︎ Jul 01 2019
🚨︎ report
[Java][JUnion] You can define struct types (value types) in Java with @Struct annotation.
@Struct
public class SomeStruct { public int id; public float val; } 
...
SomeStruct[] arr = new SomeStruct[1000];
arr[1].id = 10;

The benefit is arr uses around 8000 bytes, whereas if it were filled with objects it would use 28000 or more bytes. The downside is, structs do not use inheritance, constructors, methods etc.

To run the above you need the library.

πŸ‘︎ 41
πŸ’¬︎
πŸ‘€︎ u/itheleoi
πŸ“…︎ Apr 28 2018
🚨︎ report
The Java Ecosystem’s Obsession with NonNull Annotations blog.jooq.org/2016/11/24/…
πŸ‘︎ 51
πŸ’¬︎
πŸ‘€︎ u/nicolaiparlog
πŸ“…︎ Nov 24 2016
🚨︎ report
Java 8 null type annotations in Eclipse Luna (v4.4) - your last NullPointerException ever, The End of the World as we know it? ;-) blog2.vorburger.ch/2014/0…
πŸ‘︎ 102
πŸ’¬︎
πŸ‘€︎ u/thesystemx
πŸ“…︎ Jul 09 2014
🚨︎ report
Python’s decorators vs Java’s annotations, same thing? medium.com/@dmi3coder/pyt…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/dmi3coder
πŸ“…︎ Dec 11 2019
🚨︎ report
Java: Stricter types with Java 8 Type Annotations mscharhag.com/2014/02/jav…
πŸ‘︎ 93
πŸ’¬︎
πŸ‘€︎ u/michschar
πŸ“…︎ Feb 09 2014
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.