Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro ao chamar funcao sorteia sem biblioteca dentro de um vetor #1037

Open
MarcosCoelhoo opened this issue Mar 23, 2022 · 1 comment
Open
Labels
bug Indica que ocorreu um erro inesperado no programa/código

Comments

@MarcosCoelhoo
Copy link

br.univali.ps.nucleo.ExcecaoAplicacao: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at br.univali.ps.nucleo.TratadorExcecoes.transformarExcecao(TratadorExcecoes.java:278)
at br.univali.ps.nucleo.TratadorExcecoes.exibirExcecao(TratadorExcecoes.java:43)
at br.univali.ps.ui.abas.AbaCodigoFonte$AcaoExecucao.actionPerformed(AbaCodigoFonte.java:1099)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at br.univali.ps.ui.abas.AbaCodigoFonte$AcaoExecucao.actionPerformed(AbaCodigoFonte.java:1090)
... 40 more
Caused by: java.lang.NullPointerException
at br.univali.portugol.nucleo.execucao.gerador.helpers.Utils.getNomeTipoJava(Utils.java:282)
at br.univali.portugol.nucleo.execucao.gerador.helpers.GeradorDeclaracaoVariavel.gera(GeradorDeclaracaoVariavel.java:107)
at br.univali.portugol.nucleo.execucao.gerador.GeradorCodigoJava$VisitorGeracaoCodigo.visitar(GeradorCodigoJava.java:527)
at br.univali.portugol.nucleo.execucao.gerador.GeradorCodigoJava$VisitorGeracaoCodigo.visitar(GeradorCodigoJava.java:108)
at br.univali.portugol.nucleo.asa.NoVetor.aceitar(NoVetor.java:54)
at br.univali.portugol.nucleo.execucao.gerador.helpers.GeradorDeclaracaoVariavel.gera(GeradorDeclaracaoVariavel.java:147)
at br.univali.portugol.nucleo.execucao.gerador.GeradorCodigoJava$VisitorGeracaoCodigo.visitar(GeradorCodigoJava.java:520)
at br.univali.portugol.nucleo.execucao.gerador.GeradorCodigoJava$VisitorGeracaoCodigo.visitar(GeradorCodigoJava.java:108)
at br.univali.portugol.nucleo.asa.NoDeclaracaoVetor.aceitar(NoDeclaracaoVetor.java:84)
at br.univali.portugol.nucleo.execucao.gerador.helpers.Utils.visitarBlocos(Utils.java:264)
at br.univali.portugol.nucleo.execucao.gerador.helpers.GeradorDeclaracaoMetodo.gera(GeradorDeclaracaoMetodo.java:67)
at br.univali.portugol.nucleo.execucao.gerador.GeradorCodigoJava$VisitorGeracaoCodigo.geraMetodos(GeradorCodigoJava.java:335)
at br.univali.portugol.nucleo.execucao.gerador.GeradorCodigoJava.gera(GeradorCodigoJava.java:104)
at br.univali.portugol.nucleo.compilador.Compilador.geraPrograma(Compilador.java:163)
at br.univali.portugol.nucleo.compilador.Compilador.compilar(Compilador.java:104)
at br.univali.portugol.nucleo.Portugol.compilar(Portugol.java:29)
at br.univali.portugol.nucleo.Portugol.compilarParaExecucao(Portugol.java:48)
at br.univali.ps.ui.abas.AbaCodigoFonte.lambda$compilaProgramaParaExecucao$4(AbaCodigoFonte.java:1906)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Código do Erro:
programa
{
inclua biblioteca Util
--> u

funcao analisar(inteiro num[]) {
escreva("====== ANALISANDO O VETOR ======\n")
escreva("O vetor possui ",u.numero_elementos(num)," elementos...\n")
escreva("Os elementos são: \n")
para (inteiro c = 0; c<u.numero_elementos(num); c++) {
escreva("[",c,"]-> ",num[c]," ")
u.aguarde(300)
}
escreva("\nValores pares nas posições: ")
para (inteiro c = 0; c<u.numero_elementos(num); c++) {
se (num[c]%2==0) {
escreva(c," ")
u.aguarde(300)
}
}
escreva("\nValores ímpares nas posições: ")
para (inteiro c = 0; c<u.numero_elementos(num); c++) {
se (num[c]%2!=0) {
escreva(c," ")
u.aguarde(300)
}
}
escreva("\n================================")
}
funcao inicio()
{
inteiro vet[] = {sorteia(1,10),sorteia(1,10),sorteia(1,10),sorteia(1,10),sorteia(1,10),sorteia(1,10),sorteia(1,10),sorteia(1,10)}
analisar(vet)
}
}

@AdsonEsteves
Copy link
Member

@LudTheW
Coloque u. antes de chamar a função sorteia deve resolver.

@AdsonEsteves AdsonEsteves added the bug Indica que ocorreu um erro inesperado no programa/código label Mar 24, 2022
@AdsonEsteves AdsonEsteves changed the title Erro numero 5bc1fe9166cc47fe7097687613fbfb4ee5d5371c v2.7.5 Erro ao chamar funcao sorteia sem biblioteca dentro de um vetor Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indica que ocorreu um erro inesperado no programa/código
Projects
None yet
Development

No branches or pull requests

2 participants