processing / processing/processing4

Detect `InvocationTargetException` when initializing global variables outside setup

Aperta
#252 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement help wanted
Lingua principale
Java
Stelle
494
Fork
183
Merge medio
4h 39m
PR unite (30g)
3

Descrizione

Created by: mglst

Current Behavior

Whilst coding I ran into RuntimeException: java.lang.reflect.InvocationTargetException. It only took a google search to find another user on the Processing Foundation Forum with the same issue, and a well explained fix: https://discourse.processing.org/t/just-starting-to-code-and-code-returns-java-lang-reflect-invocationtargetexception-error/14615/2.
There are many weird exception catching things that the Processing IDE already does to mitigate the most common of these Processing-specific oddities. The post that I link to has 2.1k, so I can safely say I'm neither the first nor last person to run into this. I find that the way Java errors are thrown is quite confusing. For instance, it complains about code at a specified line, but this refers to the 'java' file rather than the 'pde' file that I'm working on - this is not obvious and can be a source for more confusion still if I go looking for a bug at the wrong place in my code ("what even are .java files? and what do you mean I have to 'export' as application to get a glimpse at it?")

Steps to Reproduce

  1. see code from https://discourse.processing.org/t/just-starting-to-code-and-code-returns-java-lang-reflect-invocationtargetexception-error/14615

Your Environment

  • Processing version: 4.0a5
  • Operating System and OS version: macOS 12.0B5

Solutions

I would like the IDE to detect when making such errors and warn me that I'm likely doing something wrong by defining initialising global variables outside of setup - especially since this seems like something which is fine for ints, booleans, bytes, ... (as I understand, all primitives - although confusingly also Strings)
The fact that this is a RunTime error makes me believe that this might be a tricky suggestion to implement, but I'd hope that it would be a useful enough feature to be worth the cost

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione collegata del Processing Forum e con il comportamento esistente dell'IDE nella gestione delle eccezioni. Determina in che modo l'inizializzazione di variabili globali al di fuori di setup produca InvocationTargetException, quindi definisci come l'IDE debba rilevarlo e mostrare un avviso che rimandi al codice PDE dell'utente. Il lavoro è completato quando il caso segnalato riceve una diagnosi chiara e specifica di Processing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
developer-experience
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.